Indexing fields without storing


(Andrej) #1

Maybe its simple or stupid, but I didnt find an answer to this
question: Is there a way to index fields, but not to store them? I
have large text fields where I just want to search for a word, but
never really return the whole field. What would be a good (meaning
memory efficient) way to do this?

Thanks in advance!
Andrej


(Jérémie BORDIER) #2

On Fri, Nov 4, 2011 at 4:42 PM, Andrej Rosenheinrich
andrej.rosenheinrich@unister.de wrote:

Maybe its simple or stupid, but I didnt find an answer to this
question: Is there a way to index fields, but not to store them? I
have large text fields where I just want to search for a word, but
never really return the whole field. What would be a good (meaning
memory efficient) way to do this?

Thanks in advance!
Andrej

Hello Andrej,

Fields are never stored on their own appart from _source. Since 0.18
it's possible to exclude fields from being stored in _source. You can
set this setting by manually defining the mappings before indexing,
with a syntax similar to:

"mappings" : {
"mytype" : {
"_source" : {
"excludes" : [ "content" ]
},
...

HTH,
Jérémie

--
Jérémie 'ahFeel' BORDIER


(Benjamin Devèze) #3

Hello Andrej,

Jérémie I think what you say is not completely right. Fields can be
configured in mapping to be stored even if by default most of core fields
have store set to no. When the value of a field is fetched, it can be
fetched from the stored value in lucene index or extracted from the stored
_source (if _source is enabled which is the default).

For the big text fields you want to index but don't want to retrieve you
can set "store" to "no" for these fields.


(Jérémie BORDIER) #4

Hello Benjamin,

What I meant, is that fields are not stored by default :wink: Thanks for
you precision.

Jérémie

On Fri, Nov 4, 2011 at 5:12 PM, Benjamin Devèze
benjamin.deveze@gmail.com wrote:

Hello Andrej,
Jérémie I think what you say is not completely right. Fields can be
configured in mapping to be stored even if by default most of core fields
have store set to no. When the value of a field is fetched, it can be
fetched from the stored value in lucene index or extracted from the stored
_source (if _source is enabled which is the default).
For the big text fields you want to index but don't want to retrieve you can
set "store" to "no" for these fields.

--
Jérémie 'ahFeel' BORDIER


(Benjamin Devèze) #5

Hey Jérémie,

no problem. And thanks for the exclude feature by the way :wink:


(dean) #6

How can I index fields without storing by using Java API?


(system) #7