Here's my solution. I'm posting it in case it is radically wrong; I
hope someone can help straighten me out. It seems to work fine, and
seems fast enough.

In schema.xml:

<fieldType name="autocomplete" class="solr.TextField">
        <analyzer type="index">
            <tokenizer class="solr.KeywordTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory" />
            <filter class="solr.PatternReplaceFilterFactory"
pattern="([^a-z0-9])" replacement="" replace="all" />
            <filter class="solr.EdgeNGramFilterFactory"
maxGramSize="100" minGramSize="1" />
        </analyzer>
        <analyzer type="query">
            <tokenizer class="solr.KeywordTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory" />
            <filter class="solr.PatternReplaceFilterFactory"
pattern="([^a-z0-9])" replacement="" replace="all" />
            <filter class="solr.PatternReplaceFilterFactory"
pattern="^(.{20})(.*)?" replacement="$1" replace="all" />
        </analyzer>
</fieldType>

<field name="ac_name" type="autocomplete" indexed="true" stored="true"
multiValued="true"/>

Then I restarted solr to pick up the changes.

I then ran a script which reads each document out of the current
index, and adds the new field:

for each doc in my solr index:

doc['ac_name'] = doc['name'].split(' ')

and write the record back out.

Then, using rsolr, I make the following query:

response = @solr.select(:params => {
        :q=> "ac_name:#{prefix}",
        :start=> 0,
        :rows=> 500,
        :fl => "name"
})
matches = []
docs = response['response']['docs']
docs.each {|doc|
        matches.push(doc['name'])
}

"matches" is now an array of the values I want to display.

Reply via email to