Hi Peter,

Use KeywordTokenizerFactory instead of Whitespace tokenizer.

Also you might interested in this : 
http://www.cominvent.com/2012/01/25/super-flexible-autocomplete-with-solr/

Ahmet



On Thursday, January 9, 2014 6:35 PM, PeterKerk <vettepa...@hotmail.com> wrote:
Basically a user starts typing the first letters of a city and I want to
return citynames that start with those letters, case-insensitive and not
splitting the cityname on separate words (whether the separator is a
whitespace or a "-").
But although the search of a user is case-insensitive, I want to return the
values including casing, search on "new york" would return "New York", where
the latter is how it's stored in my MS-SQL DB.

I've been testing my code via the admin/analysis page.

I believe I don't want the WhitespaceTokenizerFactory on my field definition
since that splits the city names I want the following behavior:

query on:

"new*" returns "New york" or "newbee", but does not return values like
"greater new hampshire"
"york*" does NOT return "new york"

"nij*" returns "Nijmegen", but not "Halle-Nijman"

Here's what I have come up so far:

    <field name="title" type="text_lower_exact" indexed="true" stored="true"/>
    <field name="title_search" type="text_lower_exact" indexed="true"
stored="true"/>


    <fieldType name="text_lower_exact" class="solr.TextField"
positionIncrementGap="100">
      <analyzer type="index">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true"
words="stopwords_dutch.txt"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
      </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
ignoreCase="true" expand="true"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true"
words="stopwords_dutch.txt"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
      </analyzer>
    </fieldType>    
    
    
    But when I leave out the WhitespaceTokenizerFactory I get:  Plugin init
failure for [schema.xml] fieldType "text_lower_exact": analyzer without
class or tokenizer,trace=org.apache.solr.common.SolrException: SolrCore
'tt-cities' is not available due to init failure



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Searchquery-on-field-that-contains-space-tp4110166p4110495.html

Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to