You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/12/09 15:39:14 UTC

[GitHub] [lucene-solr] tkaessmann opened a new pull request #2135: [SOLR-15038]: Add elevateDocsWithoutMatchingQ and onlyElevatedReprese…

tkaessmann opened a new pull request #2135:
URL: https://github.com/apache/lucene-solr/pull/2135


   **Same PR like https://github.com/apache/lucene-solr/pull/2134 but this if for Solr 8.**
   
   We've worked a lot with Query Elevation component in the last time and we were missing two features:
   
   Elevate only documents that are part of the search result
   In combination with collapsing: Only show the representative if the elevated documents does have the same collapse field value.
   Because of this, we've added these two feature toggles elevateDocsWithoutMatchingQ and onlyElevatedRepresentative.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] jbampton commented on a change in pull request #2135: SOLR-15038: Add elevateDocsWithoutMatchingQ and onlyElevatedReprese…

Posted by GitBox <gi...@apache.org>.
jbampton commented on a change in pull request #2135:
URL: https://github.com/apache/lucene-solr/pull/2135#discussion_r543423038



##########
File path: solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
##########
@@ -504,25 +506,27 @@ private void setQuery(ResponseBuilder rb, Elevation elevation) {
 
     // Change the query to insert forced documents
     SolrParams params = rb.req.getParams();
-    if (params.getBool(QueryElevationParams.EXCLUSIVE, false)) {
-      // We only want these elevated results
-      rb.setQuery(new BoostQuery(elevation.includeQuery, 0f));
-    } else {
-      BooleanQuery.Builder queryBuilder = new BooleanQuery.Builder();
-      queryBuilder.add(rb.getQuery(), BooleanClause.Occur.SHOULD);
-      queryBuilder.add(new BoostQuery(elevation.includeQuery, 0f), BooleanClause.Occur.SHOULD);
-      if (elevation.excludeQueries != null) {
-        if (params.getBool(QueryElevationParams.MARK_EXCLUDES, false)) {
-          // We are only going to mark items as excluded, not actually exclude them.
-          // This works with the EditorialMarkerFactory.
-          rb.req.getContext().put(EXCLUDED, elevation.excludedIds);
-        } else {
-          for (TermQuery tq : elevation.excludeQueries) {
-            queryBuilder.add(tq, BooleanClause.Occur.MUST_NOT);
+    if(params.getBool(ELEVATE_DOCS_WITHOUT_MATCHING_Q, true)) {

Review comment:
       ```suggestion
       if (params.getBool(ELEVATE_DOCS_WITHOUT_MATCHING_Q, true)) {
   ```

##########
File path: solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
##########
@@ -569,15 +570,18 @@ public int docID() {
     private IntArrayList boostDocs;
     private MergeBoost mergeBoost;
     private boolean boosts;
+    private boolean onlyElevatedRepresentativeVisible;
 
     public OrdScoreCollector(int maxDoc,
                              int segments,
                              DocValuesProducer collapseValuesProducer,
                              int nullPolicy,
                              IntIntHashMap boostDocsMap,
-                             IndexSearcher searcher) throws IOException {
+                             IndexSearcher searcher,
+                             boolean onlyElevatedRepresentativeVisible) throws IOException {
       this.maxDoc = maxDoc;
       this.contexts = new LeafReaderContext[segments];
+      this.onlyElevatedRepresentativeVisible = onlyElevatedRepresentativeVisible;
       List<LeafReaderContext> con = searcher.getTopReaderContext().leaves();
       for(int i=0; i<con.size(); i++) {

Review comment:
       ```suggestion
         for(int i = 0; i < con.size(); i++) {
   ```

##########
File path: solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
##########
@@ -1028,25 +1043,25 @@ public OrdFieldValueCollector(int maxDoc,
       this.needsScores4Collapsing = needsScores4Collapsing;
       this.needsScores = needsScores;
       if (null != sortSpec) {
-        this.collapseStrategy = new OrdSortSpecStrategy(maxDoc, nullPolicy, valueCount, groupHeadSelector, this.needsScores4Collapsing, this.needsScores, boostDocs, sortSpec, searcher, collapseValues);
+        this.collapseStrategy = new OrdSortSpecStrategy(maxDoc, nullPolicy, valueCount, groupHeadSelector, this.needsScores4Collapsing, this.needsScores, boostDocs, sortSpec, searcher, onlyElevatedRepresentativeVisible);
       } else if (funcQuery != null) {
-        this.collapseStrategy =  new OrdValueSourceStrategy(maxDoc, nullPolicy, valueCount, groupHeadSelector, this.needsScores4Collapsing, this.needsScores, boostDocs, funcQuery, searcher, collapseValues);
+        this.collapseStrategy =  new OrdValueSourceStrategy(maxDoc, nullPolicy, valueCount, groupHeadSelector, this.needsScores4Collapsing, this.needsScores, boostDocs, funcQuery, searcher, onlyElevatedRepresentativeVisible);

Review comment:
       ```suggestion
           this.collapseStrategy = new OrdValueSourceStrategy(maxDoc, nullPolicy, valueCount, groupHeadSelector, this.needsScores4Collapsing, this.needsScores, boostDocs, funcQuery, searcher, onlyElevatedRepresentativeVisible);
   ```

##########
File path: solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
##########
@@ -1028,25 +1043,25 @@ public OrdFieldValueCollector(int maxDoc,
       this.needsScores4Collapsing = needsScores4Collapsing;
       this.needsScores = needsScores;
       if (null != sortSpec) {
-        this.collapseStrategy = new OrdSortSpecStrategy(maxDoc, nullPolicy, valueCount, groupHeadSelector, this.needsScores4Collapsing, this.needsScores, boostDocs, sortSpec, searcher, collapseValues);
+        this.collapseStrategy = new OrdSortSpecStrategy(maxDoc, nullPolicy, valueCount, groupHeadSelector, this.needsScores4Collapsing, this.needsScores, boostDocs, sortSpec, searcher, onlyElevatedRepresentativeVisible);
       } else if (funcQuery != null) {
-        this.collapseStrategy =  new OrdValueSourceStrategy(maxDoc, nullPolicy, valueCount, groupHeadSelector, this.needsScores4Collapsing, this.needsScores, boostDocs, funcQuery, searcher, collapseValues);
+        this.collapseStrategy =  new OrdValueSourceStrategy(maxDoc, nullPolicy, valueCount, groupHeadSelector, this.needsScores4Collapsing, this.needsScores, boostDocs, funcQuery, searcher, onlyElevatedRepresentativeVisible);
       } else {
         NumberType numType = fieldType.getNumberType();
         if (null == numType) {
           throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "min/max must be either Int/Long/Float based field types");
         }
         switch (numType) {
           case INTEGER: {
-            this.collapseStrategy = new OrdIntStrategy(maxDoc, nullPolicy, valueCount, groupHeadSelector, this.needsScores, boostDocs, collapseValues);
+            this.collapseStrategy = new OrdIntStrategy(maxDoc, nullPolicy, valueCount, groupHeadSelector, this.needsScores, boostDocs, onlyElevatedRepresentativeVisible);
             break;
           }
           case FLOAT: {
-            this.collapseStrategy = new OrdFloatStrategy(maxDoc, nullPolicy, valueCount, groupHeadSelector, this.needsScores, boostDocs, collapseValues);
+            this.collapseStrategy = new OrdFloatStrategy(maxDoc, nullPolicy, valueCount, groupHeadSelector, this.needsScores, boostDocs, onlyElevatedRepresentativeVisible);
             break;
           }
           case LONG: {
-            this.collapseStrategy =  new OrdLongStrategy(maxDoc, nullPolicy, valueCount, groupHeadSelector, this.needsScores, boostDocs, collapseValues);
+            this.collapseStrategy =  new OrdLongStrategy(maxDoc, nullPolicy, valueCount, groupHeadSelector, this.needsScores, boostDocs, onlyElevatedRepresentativeVisible);

Review comment:
       ```suggestion
               this.collapseStrategy = new OrdLongStrategy(maxDoc, nullPolicy, valueCount, groupHeadSelector, this.needsScores, boostDocs, onlyElevatedRepresentativeVisible);
   ```

##########
File path: solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
##########
@@ -804,9 +812,11 @@ public IntScoreCollector(int maxDoc,
                              int size,
                              String field,
                              IntIntHashMap boostDocsMap,
-                             IndexSearcher searcher) {
+                             IndexSearcher searcher,
+                             boolean onlyElevatedRepresentativeVisible) {
       this.maxDoc = maxDoc;
       this.contexts = new LeafReaderContext[segments];
+      this.onlyElevatedRepresentativeVisible = onlyElevatedRepresentativeVisible;
       List<LeafReaderContext> con = searcher.getTopReaderContext().leaves();
       for(int i=0; i<con.size(); i++) {

Review comment:
       ```suggestion
         for(int i = 0; i < con.size(); i++) {
   ```

##########
File path: solr/solrj/src/java/org/apache/solr/common/params/QueryElevationParams.java
##########
@@ -55,4 +55,16 @@
    * they be subject to whatever the sort criteria is?  True by default.
    */
   String USE_CONFIGURED_ELEVATED_ORDER = "useConfiguredElevatedOrder";
+
+  /**
+   * By default, the component will also elevate docs that aren't part of the search result (matching the query).
+   * If you only want to elevate the docs that are part of the search result, set this to false. True by default.
+   */
+  String ELEVATE_DOCS_WITHOUT_MATCHING_Q = "elevateDocsWithoutMatchingQ";
+
+  /**
+   * If elevation is used in combination with the collapse query parser, we can define that we only want to return the
+   * representative and not all elevated docs.
+   */
+  String ONLY_ELEVATED_REPRESENTATIVE = "onlyElevatedRepresentative";
 }

Review comment:
       ```suggestion
   }
   
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] tkaessmann commented on pull request #2135: SOLR-15038: Add elevateDocsWithoutMatchingQ and onlyElevatedReprese…

Posted by GitBox <gi...@apache.org>.
tkaessmann commented on pull request #2135:
URL: https://github.com/apache/lucene-solr/pull/2135#issuecomment-778279414


   not needed anymore


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] tkaessmann closed pull request #2135: SOLR-15038: Add elevateDocsWithoutMatchingQ and onlyElevatedReprese…

Posted by GitBox <gi...@apache.org>.
tkaessmann closed pull request #2135:
URL: https://github.com/apache/lucene-solr/pull/2135


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org