Using Solr for searching docs in English and Korean languages, so far Korean language search is working fine. Need to extend English exact phrase to match with partial words too.
Solr query I used:
content: "He go"
is not matching with He goes, He gone, He goal, etc.
I tried with like these but not worked
content: "He go"*
content: "He go*"
Current field schema
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.CJKBigramFilterFactory" han="false" hiragana="false" katakana="false" hangul="true" outputUnigrams="true" />
</analyzer>
</fieldType>
So my input and expected output is given below:
Input: He go ( with quote)
Output: He goes, He gone, He goals ( should match with docs having those words, can be a partial match )
How can I achieve this functionality, any suggestion is highly appreciated.
If you want to search by parts of a word, you need apply, for example, N-Gram Tokenizer,
<tokenizer class="solr.NGramTokenizerFactory" minGramSize="3" maxGramSize="10"/>eg.
In:
"bicycle"Out:
"bicy", "bicyc", "icyc", "icycl", "cycl", "cycle", "ycle"In this case you will be able to search by the part of word. You need apply the NGramTokenizerFactory for both analyzers:
If you use the above field type then analysis of the same on the admin tool is as below.
You can also try the below query analyzer. It all depends on your requirement.
You can modify or add the field types in your
schema.xmland apply it to your field. Once done restart the server, re-index the data. You can verify the above fieldType for your field if the data matches using solr admin tool.I have used the below field type and done the analysis using the solr tool.
Here is the field type :
Please find the analysis of the same from the solr admin tool.