我让我的 SOLR 开始工作,它工作得很好,但我不知道托管模式到底是什么,因为我确实使用了默认版本,我在其中添加了我的案例所需的几行
<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
我是否必须将所有内容都保留为默认示例?我没有任何线索... 您有典型架构文件的示例吗?
最佳答案
您应该使用 Solr 的 Schema API。可以在此处找到更多信息:https://lucene.apache.org/solr/guide/7_2/schema-api.html
这基本上意味着您从 shell 发出 curl -X POST
(到本地主机)来编辑文件。
例子:
: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 界面来构建和发出这些本地主机命令。我知道如果有动物园管理员,事情会变得棘手,但是在单个服务器上进行基本探索应该是微不足道的,目前不是。这种方法将显示格式化的 curl
命令,以便培训新开发人员正确使用。
开发人员必须将此类文档中的 xml 转换为正确的 json 以用于 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 managed-schema,如何使用它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39988999/