Hi,
I'll explain what I am trying to do - I'm not sure if it is entirely possible!
Basically, I have an entity with multiple fields that are stored in the index (store = Store.YES). I'm using projections to return just the fields that I am interested in, but I only want those fields that actually match to be returned. At the moment, when 1 field matches, all fields are returned in the object[].
Here is some code that may explain better:
Code:
String[] assetFields = new String[]{"description","notes","reference","manufInfo"};
MultiFieldQueryParser assetParser = new MultiFieldQueryParser(assetFields, new StandardAnalyzer());
assetParser.setDefaultOperator(Operator.AND);
org.apache.lucene.search.Query assetQuery = assetParser.parse(term);
org.hibernate.search.FullTextQuery assetQueryRes = fullTextSession.createFullTextQuery(assetQuery,Asset.class);
assetQueryRes.setProjection("description","notes","reference","manufInfo");
List<Object[]> assetResults = assetQueryRes.list();
Now lets say I have an Asset with the following values for the fields:
description = "personal mobile."
notes = "Just some random notes."
reference = "Just a reference."
manufInfo = "Three"
If my search term is "no*" (I'm using a wildcard here) then the result array has all the results, but basically I just want the notes field.
Is this possible?
Thanks in advance!
K