0
votes

Consider the following schema,

<schema>

<types>
    <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true" multiValued="false"/>
    <fieldType name="stop_analyzer_string" class="solr.TextField" multiValued="false">
       <analyzer type="index">
          <tokenizer class="solr.WhitespaceTokenizerFactory"/>
          <filter class="solr.LowerCaseFilterFactory"/>
          <filter class="solr.StopFilterFactory" words="stopwords.txt" ignoreCase="true"/>
          <filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="50" side="front"/>
      </analyzer>
     <analyzer type="query">
       <tokenizer class="solr.WhitespaceTokenizerFactory"/>
       <filter class="solr.LowerCaseFilterFactory"/>
       <filter class="solr.StopFilterFactory" words="stopwords.txt" ignoreCase="true"/>
    </analyzer>
   </fieldType>
</types>

<fields>
   <field name="name_search" type="stop_analyzer_string" indexed="true" stored="false"/>
   <copyField source="name" dest="name_search"/>
   <field name="name" type="string" indexed="true" stored="true"/>
</fields>

</schema>

The name field gets indexed with WhitespaceTokenizerFactory, but it doesn't seem to use the WhitespaceTokenizerFactory while querying with the name field.

For a doc with name as "solr search",
the query name_search:solr - matches the document. //index time WhiteSpace tokenizer works
the query name_search:search - matches the document. //index time WhiteSpace tokenizer works
But the query name_search:solr search - doesn't match the document. //query time WhiteSpace tokenizer doesn't work

But as specified in the schema, the query should also be tokenized with whitespace and matched with the document. no?

1

1 Answers

0
votes

Not sure what you are missing, but all the above queries worked for me for the data that you mentioned.

http://localhost:8983/solr/collection1/select?q=name_search%3Asolr+search&wt=xml&indent=true

The above returned result document i indexed.

Just to test do this:

http://localhost:8983/solr/#/collection1/documents

Got to : And paste below document as is into your Document(s) part and hit Submit Document

{"id":"100001","name_search":"solr search"}

Run you query as:

http://localhost:8983/solr/collection1/select?q=name_search%3Asolr+search&wt=json&indent=true