4

What is the intension of index = Index.YES and store = Store.YES on @Field. At the end (when a search is executed) would this data be loaded from the database (search over the index and load results from database)? Why should I store the data in index too?

Or is my understanding wrong?

Francisco Spaeth
  • 23,493
  • 7
  • 67
  • 106
  • Why don't you read the [javadoc](http://docs.jboss.org/hibernate/search/4.0/api/org/hibernate/search/annotations/Field.html)? – Bohemian May 14 '12 at 19:06
  • 4
    In fact I did it, but it simple doesn't clarify that much: Returns a {@code Index} enum defining whether the value should be indexed or not. Defaults to {@code Index.YES} and Returns a {@code Analyze} enum defining whether the value should be analyzed or not. Defaults to {@code Analyze.YES}. – Francisco Spaeth May 14 '12 at 19:36

2 Answers2

7

store : describe whether or not the property is stored in the Lucene index. You can store the value Store.YES (consuming more space in the index but allowing projection, see Section 6.1.2.5, “Projection” for more information), store it in a compressed way Store.COMPRESS (this does consume more CPU), or avoid any storage Store.NO (this is the default value). When a property is stored, you can retrieve it from the Lucene Document (note that this is not related to whether the element is indexed or not).

index: describe how the element is indexed (i.e. the process used to index the property and the type of information store). The different values are Index.NO (no indexing, i.e. cannot be found by a query), Index.TOKENIZED (use an analyzer to process the property), Index.UN_TOKENISED (no analyzer pre-processing), Index.NO_NORM (do not store the normalization data). The default value is TOKENIZED.

According: http://docs.redhat.com/docs/en-US/JBoss_Enterprise_Application_Platform/4.2/html/Hibernate_Search_Reference_Guide/Hibernate_Search-Mapping.html

Francisco Spaeth
  • 23,493
  • 7
  • 67
  • 106
  • 2
    storing the value in the index is also required for sorting the query results. – mdma Nov 02 '12 at 01:53
  • 2
    @mdma No need to store for sorting only, https://forum.hibernate.org/viewtopic.php?f=9&t=999211&view=next#p2417036. – sp00m Oct 12 '14 at 17:36
  • for hibernate search 5.7.Final(the latest as of time of writing) your answer is wrong :) – niceman Mar 21 '17 at 13:00
  • @niceman would you be so kind and provide the documentation page to update the answer? In fact the answer was based on documentation referred accordingly (based on Hibernate 4.2) – Francisco Spaeth Mar 21 '17 at 17:49
  • sure , here it is : https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#search-mapping-entity – niceman Mar 22 '17 at 11:12
0

I think the documentation is quite clear - http://docs.jboss.org/hibernate/search/4.1/reference/en-US/html_single/#basic-mapping

Other than that storing the index data in the Lucene index is required if you want to use the projection feature. Again, this is explained in the documentation.

Hardy
  • 18,659
  • 3
  • 49
  • 65
  • Depending on the version of Search you are using you can pick the appropriate documentation here - http://www.hibernate.org/subprojects/search/docs – Hardy May 15 '12 at 09:27