Why doesn't Solr query work on spaces?
Aswin Raghavan
I'm a beginner in Solr and have the following set of indexes in my Soleserver:
{
"id": "book5",
"title": [
"Five point someone"
],
"author": "Chetan Bagat",
"genere": "fantasy",
"description": [
"An iit guide"
],
"comments": [
"good",
"excellent"
],
"publications": [
"swapnapublications",
"pb publications"
]
}
and
{
"id": "book1",
"title": [
"nightatcallcenter"
],
"author": "ChetanBagat",
"genere": "fiction",
"description": [
"Aniitguide"
],
"comments": [
"good",
"excellent"
],
"publications": [
"bangalorepublications",
"aswinpublications"
]
}
my query q = five + points + someone failed
but my query
q = nightatcallcenter stays in good shape, why is this happening? How do I make the first query work
My schema:
<fields>
<field name="id" type="text_general" indexed="true" stored="true" required="true" multiValued="false" />
<field name="title" type="text_general" indexed="true" stored="true" multiValued="true"/
<field name="genere" type="text_general" indexed="true" stored="true"/>
<field name="description" type="text_general" indexed="true" stored="true" multiValued="true"/>
<field name="comments" type="text_general" indexed="true" stored="true" multiValued="true"/>
<field name="author" type="text_general" indexed="true" stored="true" />
<field name="publications" type="text_general" indexed="true" stored="true" multiValued="true" />
<copyField source='*' dest='fulltext'/>
<field name='fulltext' type='text_general' multiValued='true '/>
</fields>
Alex
The problem you are having is using text_general
, you are creating a token. When searching Five +point+someone
, you are looking for three markers:
- Fives
- View
- someone
A clean solution you can use is to create a custom code text_general
like this:
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>