开发者

Solr Sunspot non-indexed field

开发者 https://www.devze.com 2023-03-08 04:52 出处:网络
Solr (via Lucene) supports different ways to indicate the way a field is indexed in a document: indexed, tokenized, stored,...

Solr (via Lucene) supports different ways to indicate the way a field is indexed in a document: indexed, tokenized, stored,...

I'm looking for a way to have fie开发者_如何学Clds that are stored in Solr but are not indexed. Is there a way to achieve that in Sunspot?


Sunspot's configuration DSL supports an option of :stored => true for many of its default types. For the example of the stored string, it would be much simpler than my first example:

searchable do
  string :name, :stored => true
end

This generates a field name of name_ss corresponding to the following dynamicField already present in Sunspot's standard schema:

<dynamicField name="*_ss" stored="true" type="string" multiValued="false" indexed="true"/>

You can also create your own custom field or dynamicField in your schema.xml to be stored but not indexed, and then use the Sunspot 1.2 :as option to specify a corresponding field name.

For example, a more verbose version of the above. In your schema:

<dynamicField name="*_stored_string" type="string" indexed="false" stored="true" />

And in your model:

searchable do
  string :name, :as => 'name_stored_string'
end


You can try :

http://localhost:8983/solr/admin/luke?numTerms=0

And read with xpath or regex those fields with schema attribute value:

<str name="I">Indexed</str>
<str name="T">Tokenized</str>
<str name="S">Stored</str>

You will get something like:

<lst name="field">
<str name="type">stringGeneralType</str>
<str name="schema">--SM---------</str>
</lst>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号