如何使text_ws字段不区分大小写

时间:2019-04-03 07:58:09

标签: c# apache solr

我在Solr中使用text_ws字段,例如:当我搜索足球时,当Solr包含足球之类​​的数据时,它不会显示任何结果。

当我搜索“足球”,“足球”或“足球”时,应该给出与足球相关的结果,我想使用不区分大小写的text_ws字段。

1 个答案:

答案 0 :(得分:0)

默认的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"}}}}

如果您要进行不区分大小写的搜索,则需要修改此字段类型的定义,以像LowerCaseFilterFactory字段那样包含text_general这样的内容:

$ 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字段进行不区分大小写的搜索。

相关问题