开发者

How to exclude the item if it contains a single field of search term in lucene Search?

开发者 https://www.devze.com 2023-02-13 22:38 出处:网络
I am working on lucene search. Th开发者_Go百科ere is a need for me to exclude some fields from being searched. I did the exclusion of fields by using a method. The results also contains the correct re

I am working on lucene search. Th开发者_Go百科ere is a need for me to exclude some fields from being searched. I did the exclusion of fields by using a method. The results also contains the correct results , without these excluded fields. But I got a new problem that when my search term is present in some other field, the entire item is returned back without giving any priority to the excludeField list.

Let me clearly explain, for example in "Home" item, I have fields like "HeaderText, FooterText, Image". I have some contents in all these fields. Consider, I exclude the field "HeaderText". When I search a term, the "Home" item will not be shown in searchResults, even if it contains the searchterm, but when the search term is present in HeaderText and the footerText, the Search Results contains the "Home" item, even though I excluded the "HeaderText" field.

So provide me a solution for this. Thanks in prior.


Its not clear to me what exactly is needed. My best guess is that if HeaderText contains the term, then the document should be excluded from the result set even if other fields contain the term.

Instead of excluding HeaderText from being searched, try to use a negative query term. Example, NOT HeaderText:term. The syntax details are available here.

0

精彩评论

暂无评论...
验证码 换一张
取 消