我想要實現的是當我在test
之後進行搜索時,還爲我帶來了Test, TeSt, TesT,TEST
以及不區分大小寫的搜索。 我該怎麼辦?SOLR Case不敏感字段搜索問題
我在schema.xml中這種textgen
類型分配給test_field
<fieldType name="textgen" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="0"/>
<filter class="solr.LowerCaseFilterFactory"/>
</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.txt"
enablePositionIncrements="true"
/>
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="0"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="select">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="stopwords.txt"
enablePositionIncrements="true"
/>
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="0"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
這裏有,我想用我的查詢收到的結果。
{
"responseHeader":{
"status":0,
"QTime":2,
"params":{
"q":"test_field:*",
"indent":"true",
"wt":"json"}},
"response":{"numFound":5,"start":0,"docs":[
{
"id":"change.me",
"test_field":["test"],
"_version_":1546932094148542464},
{
"id":"change.me1",
"test_field":["tesT"],
"_version_":0203020288},
{
"id":"change.me2",
"test_field":["TesT"],
"_version_":3122255872},
{
"id":"change.me3",
"test_field":["TEsT"],
"_version_":7768496128},
{
"id":"change.me4",
"test_field":["TEST"],
"_version_":1546932111283322880}]
}}
當我使用此查詢它不給任何結果,因爲它是區分大小寫的,即使它有過濾LowerCaseFilterFactory
http://localhost:8983/solr/test-data/select?q=test_field:*test*&wt=json&indent=true
和空的結果。 (我做錯了什麼?)
{
"responseHeader":{
"status":0,
"QTime":2,
"params":{
"q":"test_field:*test*",
"indent":"true",
"wt":"json"}},
"response":{"numFound":1,"start":0,"docs":[
{
"id":"change.me",
"test_field":["test"],
"_version_":1546932094148542464}]
}}
您需要在添加過濾器後重新索引文檔。因此,請在重新索引文檔後檢查查詢。 –
我已經創建了一個新的模式,它的工作原理,我認爲我的舊solr模式中出現了一些問題。 –