SOLR 托管模式,如何使用? [英] SOLR managed-schema, how to use it?

查看:14
本文介绍了SOLR 托管模式,如何使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我让我的 SOLR 工作了,它工作得很好,但我不知道托管模式到底是什么,因为我确实使用了默认版本,我在其中添加了我的案例所需的几行

I got my SOLR to work, and it works decently but i have no clue what exactly managed-schema is, since I did use the default version in which i added few lines that i needed for my case

<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="name" type="text_general" indexed="true" stored="true" default="" />
<field name="brand_id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="brand_name" type="text_general" indexed="true" stored="true" default="" />
<field name="type" type="string" indexed="true" stored="true" required="true" default="0"  />

我不能包含完整的文件,因为就像 700 行...但完整的 xml 在这里 http://pastebin.com/Z9nc36QD

I cannot include the full file because is like 700 lines... but full xml is here http://pastebin.com/Z9nc36QD

我是否必须将所有内容都保留为默认示例?我没有任何线索...你有一个典型的架构文件的例子吗?

do i have to keep everything as the default example? i have no clue... do you have an example of a typical schema file?

推荐答案

您应该使用 Solr 的 Schema API.更多信息可以在这里找到:https://lucene.apache.org/solr/guide/7_2/schema-api.html

You are supposed to use Solr's Schema API. More information can be found here: https://lucene.apache.org/solr/guide/7_2/schema-api.html

这基本上意味着您从 shell 发出 curl -X POST(到本地主机)来编辑文件.

It basically means you issue curl -X POST (to localhost) from a shell to edit the file.

示例:

:curl -X POST -H 'Content-type:application/json' --data-binary '{
 "add-field-type" : {
 "name":"myNewTxtField",
 "class":"solr.TextField",
 "positionIncrementGap":"100",
 "analyzer" : {
    "charFilters":[{
       "class":"solr.PatternReplaceCharFilterFactory",
       "replacement":"$1$1",
       "pattern":"([a-zA-Z])\\1+" }],
    "tokenizer":{
       "class":"solr.WhitespaceTokenizerFactory" },
    "filters":[{
       "class":"solr.WordDelimiterFilterFactory",
       "preserveOriginal":"0" }]}}
}' http://localhost:8983/solr/gettingstarted/schema`

个人评论

现在是 2018 年,他们现有的管理控制台确实应该有一个 Web 界面来构建和发出这些 localhost 命令.我知道如果有动物园管理员,事情会变得棘手,但是在单个服务器上基本探索应该是微不足道的,目前不是.这种方法将显示格式化的 curl 命令,以便培训新开发人员正确使用.

It's 2018, there really should just be a web interface from their existing admin console to build and issue these localhost commands. I get that things can become tricky if there's a zookeeper, but basic exploration on a single server should be trivial and currently it is not. This approach would show the formatted curl command so it would train new developers on proper usage.

开发人员必须将这样的文档中的 xml 转换为用于 POST 的正确 json.

Developers have to translate the xml from documentation like this into correct json for the POST.

<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" />
    <!-- in this example, we will only use synonyms at query time
    <filter class="solr.SynonymFilterFactory"
      synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
    -->
    <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"/>
  </analyzer>
</fieldType>

这篇关于SOLR 托管模式,如何使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆