In my case, documents have two fields, for example, "title" and "views". "views" is represented the num of times that people have visited this document. like: "title":"iphone", "views":"10". I have to develop a strategy that will assign some weights to views, such as the relevance score is calculated by score(title)*0.8+score(views)*0.2. Does lucene can do this? And I want to know whether there are some algorithms related to this question.
Score Boosting Lucene allows influencing search results by "boosting" in more than one level: Document level boosting - while indexing - by calling document. setBoost() before a document is added to the index. Document's Field level boosting - while indexing - by calling field.
Lucene supports single and multiple character wildcard searches within single terms (not within phrase queries). To perform a single character wildcard search use the "?" symbol. To perform a multiple character wildcard search use the "*" symbol. You can also use the wildcard searches in the middle of a term.
You can't search for special characters in Lucene Search. These are + - = && || > < ! ( ) { } [ ] ^ " ~ * ? : \ / @. You can search for special characters, with the exception of the @ character, in a field-level search as long as you escape them using \ before the special character.
If you get here after 2020, in Lucene 8.5.2.
The ways to go:
Wrap your Query (any Query but probably TermQuery in this case) in à BoostQuery
Query boosted = new BoostQuery(query, 2f);
Use the caret ^ symbol in your query parser syntax.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With