I am trying to implement Hibernate search in my existing spring/hibernate application.
In the earlier implementation, I had a SQL like this-
select field1, field2, field3, searchField
from table1
where
field1 = 100
and field2 = 200
and field3 = 300
and searchField like '%some text%'
field1+field2+field3 is the composite primary key here.
For hibernate search, I created an entity class EntityClass, mapped field1, 2 and 3 as @Id via another @Embeddable class which defines these fields as class properties. Also defined searchField as @Field with tokenized index in the entity class.
I had an existing database, so I had to do the initial index creation manually.
This is the code I am using to execute search query-
Code:
String fields[] = new String[]("field1', "field2", "field3","searchField");
MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer());
Query luceneQuery;
luceneQuery = parser.parse("some text");
org,hibernate.Query hibQuery = fullTextSession.createFullTextQuery(luceneQuery, EntityClass.class);
List result = hibQuery.list();
My question is-
compared to the original SQL query, I am passing the value of where clause searchField condition in the parser.parse(....) line. How do I pass the values of other where clause conditions (field1, 2, 3) in the lucene/hibernate search query?
I am new to hibernate search, so please pardon my ignorance if it looks too naive.