简体   繁体   English

托管模式中的Solr用例不区分大小写字段

[英]Solr use case insensitive field in managed schema

I have a field use string type, i want it not tokenizer and case insensitive. 我有一个使用字符串类型的字段,我希望它不分词器并且不区分大小写。 I know use string field type and add a LowerCaseFilterFactory filter, but how could i do this in schemaless mode? 我知道使用字符串字段类型并添加LowerCaseFilterFactory过滤器,但是我如何在无模式下执行此操作?

There is nothing different about doing it in the "schemaless" mode - you use the Schema API to configure your Schema, or you can edit the managed schema manually if you only have one node. 没有任何关于做它的“无模式”模式不同-你使用架构API来配置你的模式,也可以手动编辑管理的架构,如果你只有一个节点。

But you can't attach a filter to a string field, so the field will have to be changed to a field type that has TextField as its base, then have it use KeywordTokenizer as its tokenizer and apply the filter to the result. 但是您不能将过滤器附加到字符串字段,因此必须将该字段更改为以TextField为基础的字段类型,然后使用KeywordTokenizer作为其标记生成器并将该过滤器应用于结果。 The KeywordTokenizer keeps the input string as a single token, which is then lowercase by your filter - and the result is the same as what you'd get with a string field with an attached filter. KeywordTokenizer将输入字符串保留为单个令牌,然后由过滤器将其转换为小写字母-结果与使用带有附加过滤器的字符串字段得到的结果相同。

You can add a new field type through the Schema API by invoking the add-field-type command on the schema endpoint : 您可以通过在模式端点上调用add-field-type命令,通过模式API添加新的字段类型:

curl -X POST -H 'Content-type:application/json' --data-binary '{
  "add-field-type" : {
     "name":"myNewTxtField",
     "class":"solr.TextField",
     "positionIncrementGap":"100",
     "analyzer":{
        "tokenizer":{
           "class":"solr.KeywordTokenizerFactory" 
        }
        "filters":[{
           "class":"solr.LowercaseFilterFactory"
        }]
     }
  }
}' http://localhost:8983/solr/gettingstarted/schema

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM