Ah,thank you very much,Hardy.it's my problem indeed.
In fact,my index contains a field whose values like this:"Tom Jack Alice Mary" (names are separated by white space).
And I need to count which names are hitted and how many of them.So i process the hit value one by one:first split
the hit value using " " and for each splitted string, i use the function String.contains(String inputWord) to find the name
that is hitted.and here,the contains(String inputWord) function made me think that PrefixQuery cannot work with analyzer.
So Hardy,if i need to find which names are hitted and how many of them,i have to process the hit results given by hibernate
search,right?
The field's values ("Tom Jack Alice Mary") are directly from database. so when building the index,is it better If I give each name a different field name.like: Field field1 = new Field("name1",Tom,...),Field field2 = new Field("name2",Jack,...) ...
document.add(field1),document.add(field2),...
Thank you!
hardy.ferentschik wrote:
Hi,
that does not sounds right. Prefix queries definitely work also in conjunction w/ analyzers. I think your problem lies somewhere else. It would help if you post you model together with your Search configuration.
One thought which comes to my mind - you are saying you have a single(?) field with the value "Tom Jack Alice Mary". If you run this through the analyzer you will get four terms "tom", "jack", "alice" and "mary". You will get a successful search if you search for any of the following t*, j*, a* or m*. All four names belong to the same field which means that as long as your query matches one of these names you will get a search result. If you want to match the names really as one single string "Tom Jack Alice Mary", you would indeed not use an analyzer. However, a* wouldn't match then either.
As said, it would really help if you describe your use case a little more.
--Hardy