Solr 索引与存储 [英] Solr index vs stored
问题描述
我对 Solr 字段的索引和存储属性的行为有些困惑.
I am a little confused as to what the behaviour of the index and stored attibutes of the Solr fields is.
例如,如果我在 Schema.xml 中有以下内容
For example if I have the following in the Schema.xml
<field name="test1" type="text" indexed="false"
stored="false" required="false" />
字段 test1 是否不会存储在 Solr 文档中,即使我创建了一个包含该字段的文档并为该字段设置了一个值并将文档提交给 Solr.由于我有 stored=false
属性,这是否意味着该字段的值在 Solr 中丢失并且没有持久化?
Will the field test1 be not stored in the Solr document even if I create a document with that field in it and set a value to that field and commit the document to Solr. As I have the stored=false
attribute, does it mean that the value of the field is lost in Solr and not persisted?
推荐答案
这是正确的.通常,您希望您的字段被索引或存储或两者兼而有之.如果您将两者都设置为 false,则该字段在您的 Solr 文档中将不可用(用于搜索或显示).当您希望将两者都设置为 false 时,请参阅 Alexandre 对特殊情况的回答.
That is correct. Typically you will want your field to be either indexed or stored or both. If you set both to false, that field will not be available in your Solr docs (either for searching or for displaying). See Alexandre's answer for the special cases when you will want to set both to false.
如此处所述:indexed=true
使字段可搜索(和可排序和facetable).例如,如果您有一个名为 test1
且带有 indexed=true
的字段,那么您可以像 q=test1:foo
一样搜索它,其中 foo
是您要搜索的值.如果字段 test1
的 indexed=false
则该查询将不会返回任何结果,即使您在 Solr 中有一个 test1
的值为 test1
的文档foo
.
As stated here : indexed=true
makes a field searchable (and sortable and facetable). For eg, if you have a field named test1
with indexed=true
, then you can search it like q=test1:foo
, where foo
is the value you are searching for. If indexed=false
for field test1
then that query will return no results, even if you have a document in Solr with test1
's value being foo
.
stored=true
意味着您可以在搜索时检索该字段.如果您想显式检索查询中字段的值,您将在查询中使用 fl
参数,例如 fl=test1
(默认为 fl=*
表示检索所有存储的字段).仅当 stored=true
对于 test1
时,才会返回该值.否则不予退还.
stored=true
means you can retrieve the field when you search. If you want to explicitly retrieve the value of a field in your query, you will use the fl
param in your query like fl=test1
(Default is fl=*
meaning retrieve all stored fields). Only if stored=true
for test1
, the value will be returned. Else it will not be returned.
这篇关于Solr 索引与存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!