0

I'm working on optimizing my Lucene index, and I'm a little unsure as to what the Field.Store is all about. Wondering if I could get a decent description.

Example:

doc.Add(New Field("user", e.Username, Field.Store.YES, Field.Index.ANALYZED))

If I've got a "user" stored in my user field, and I want to be able to search that user via user:joe do I need to Store that field Field.Store.YES? I'm just not quite sure how the store works. If it means that it's not in the index, then what would be the point of putting the "user" field in the index at all?

Chase Florell
  • 46,378
  • 57
  • 186
  • 376

1 Answers1

1

Field.Store is explained beautifully in this SO thread Lucene indexing: Store and indexing modes explained

Basically the search hits will include the data for all the fields with Field.Store.YES set, you don't need this if you have another storage mechanism like a DB. If you do rely on Lucene for this exclusively, it makes sens to store a few common fields, at least one that allows you to get to the original document on disk.

Community
  • 1
  • 1
BrokenGlass
  • 158,293
  • 28
  • 286
  • 335
  • yeah... normalli i only have store set to yes for some identification field so i can retrieve the original object from database when there is a search hit. – Pauli Østerø Jan 03 '11 at 21:39
  • so if I punch in all my fields as `Store.NO` and `Index.ANALYZED` - I still need to search on a specific `Field`. But if that specific field doesn't contain my keywords (even though the keywords are contained in a different field), then the Analyzing is moot. Is that correct? *IE: I search for joe who's in the users field but my parser is pointing to the details field, then joe will never be found* – Chase Florell Jan 03 '11 at 22:15
  • I think i figured that bit out, I'll have to use a boolean query – Chase Florell Jan 03 '11 at 22:24
  • yep as you said, terms are field specific, you can search over multiple terms in a Boolean query, I used one in my answer here: http://stackoverflow.com/questions/4565303/lucene-net-how-can-i-add-a-date-filter-to-my-search-results/4565395#4565395 – BrokenGlass Jan 03 '11 at 22:28
  • nailed it. Boolean search wasn't as straight forward as the parser. Working now though... Gotta say, I'm liking lucene.net more and more, the deeper I dig into it. – Chase Florell Jan 03 '11 at 23:08