0

I am creating an apache lucene document with skills as field and no of years of experience as value.

Document 1

Spark_exp:5

Java_exp:10

Document 2

Java_exp:20

Hadoop_exp:15

Spark_exp:10

Now user is searching with Java_exp as mandatory field with minimum exp as 10 years and Spark_exp as optional field with minimum exp as 5 years.

Currently i am doing this and it is giving constant score for matched document.I am using apache lucene 8.11.0 version.

    Query query = IntPoint.newRangeQuery("Java_exp",10,100);

    Query query2 = IntPoint.newRangeQuery("Spark_exp", 5,100);
   
    BooleanQuery booleanQuery = new BooleanQuery.Builder()
            .add(query, BooleanClause.Occur.SHOULD)
            .add(query2, BooleanClause.Occur.SHOULD)
            .build();

I am using boolean query to search and want to give higher score which has more experience in mandatory skill so that document 2 has higher score than document 1. How can i achieve the same using apache lucene.

ProblemSolver
  • 129
  • 1
  • 1
  • 8
  • An alternative approach, as a suggestion: Instead of boosting the document scores, you can sort the results: [Sorting search result in Lucene based on a numeric field](https://stackoverflow.com/q/21965778/12567365). – andrewJames Nov 27 '21 at 14:57

0 Answers0