我在Solr中使用text_ws字段,例如:当我搜索足球时,当Solr包含像足球这样的数据时,它不会显示任何结果。
当我搜索足球,足球或FOOTBALL时,它应该给出与足球相关的结果,我想使用不区分大小写的text_ws字段。
发布于 2019-04-03 21:14:52
默认的text_ws字段定义仅使用WhitespaceTokenizerFactory标记器,您可以通过
$ curl localhost:8983/solr/your-core/schema/fieldtypes/text_ws
{
"responseHeader":{
...
"fieldType":{
"name":"text_ws",
"class":"solr.TextField",
"positionIncrementGap":"100",
"analyzer":{
"tokenizer":{
"class":"solr.WhitespaceTokenizerFactory"}}}}如果要进行不区分大小写的搜索,则需要修改此字段类型的定义,以便像text_general字段那样包含类似LowerCaseFilterFactory的内容:
$ curl localhost:8983/solr/your-core/schema/fieldtypes/text_general
{
"responseHeader":{
...
"fieldType":{
"name":"text_general",
"class":"solr.TextField",
"positionIncrementGap":"100",
"multiValued":true,
"indexAnalyzer":{
"tokenizer":{
"class":"solr.StandardTokenizerFactory"},
"filters":[{
"class":"solr.StopFilterFactory",
"words":"stopwords.txt",
"ignoreCase":"true"},
{
"class":"solr.LowerCaseFilterFactory"}]},
...或者,您可以将text_ws字段的值复制到text_general字段,然后对text_general字段运行不区分大小写的搜索。
https://stackoverflow.com/questions/55489925
复制相似问题