You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "David (JIRA)" <ji...@apache.org> on 2014/02/26 00:47:19 UTC

[jira] [Commented] (SOLR-5773) CollapsingQParserPlugin problem with ElevateComponent

    [ https://issues.apache.org/jira/browse/SOLR-5773?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13912270#comment-13912270 ] 

David commented on SOLR-5773:
-----------------------------

To better illustrate what I'm talking about add the following to TestCollapseQParserPlugin.java

{code}
 String[] doc7 = {"id","7", "term_s","YYYY", "group_s", "group1", "test_ti", "10", "test_tl", "1300", "test_tf", "4020"};
    assertU(adoc(doc7));
    assertU(commit());
{code}

And now update elevate.xml

{code}
 <query text="YYYY">
  <doc id="7" />
 </query>
{code}

The result after running the test for elevate is

{code}
<response>
   <lst name="responseHeader">
      <int name="status">0</int>
      <int name="QTime">100</int>
      <lst name="params">
         <str name="q">YYYY</str>
         <str name="fq">{!collapse field=group_s}</str>
         <str name="defType">edismax</str>
         <str name="bf">field(test_ti)</str>
         <str name="qf">term_s</str>
         <str name="fl">id,term_s,group_s,test_ti,test_tl,test_tf,[elevated]</str>
         <str name="qt">/elevate</str>
      </lst>
   </lst>
   <result name="response" numFound="3" start="0">
      <doc>
         <float name="id">7.0</float>
         <str name="term_s">YYYY</str>
         <str name="group_s">group1</str>
         <int name="test_ti">10</int>
         <long name="test_tl">1300</long>
         <float name="test_tf">4020.0</float>
         <bool name="[elevated]">true</bool>
      </doc>
      <doc>
         <float name="id">2.0</float>
         <str name="term_s">YYYY</str>
         <str name="group_s">group1</str>
         <int name="test_ti">50</int>
         <long name="test_tl">100</long>
         <float name="test_tf">200.0</float>
         <bool name="[elevated]">false</bool>
      </doc>
      <doc>
         <float name="id">6.0</float>
         <str name="term_s">YYYY</str>
         <str name="group_s">group2</str>
         <int name="test_ti">10</int>
         <long name="test_tl">100</long>
         <float name="test_tf">200.0</float>
         <bool name="[elevated]">false</bool>
      </doc>
   </result>
</response>
{code}

You can see that there are now two results for group1 when all I really want is the elevated document to be shown for group1

> CollapsingQParserPlugin problem with ElevateComponent
> -----------------------------------------------------
>
>                 Key: SOLR-5773
>                 URL: https://issues.apache.org/jira/browse/SOLR-5773
>             Project: Solr
>          Issue Type: Improvement
>          Components: query parsers
>    Affects Versions: 4.6.1
>            Reporter: David
>              Labels: collapse, solr
>             Fix For: 4.7
>
>   Original Estimate: 8h
>  Remaining Estimate: 8h
>
> Hi Joel,
> I sent you an email but I'm not sure if you received it or not. I ran into a bit of trouble using the CollapsingQParserPlugin with elevated documents. To explain it simply, I want to exclude grouped documents when one of the members of the group are contained in the elevated document set. I'm not sure this is possible currently because as you explain above elevated documents are added to the request context after the original query is constructed.
> To try to better illustrate the problem. If I have 2 documents docid=1 and docid=2 and both have a groupid of 'a'. If a grouped query scores docid 2 first in the results but I have elevated docid 1 then both documents are shown in the results when I really only want the elevated document to be shown in the results.
> Is this something that would be difficult to implement? Any help is appreciated.
> I think the solution would be to remove the documents from liveDocs that share the same groupid in the getBoostDocs() function. Let me know if this makes any sense. I'll continue working towards a solution in the meantime.
> {code}
> private IntOpenHashSet getBoostDocs(SolrIndexSearcher indexSearcher, Set<String> boosted) throws IOException {
>       IntOpenHashSet boostDocs = null;
>       if(boosted != null) {
>         SchemaField idField = indexSearcher.getSchema().getUniqueKeyField();
>         String fieldName = idField.getName();
>         HashSet<BytesRef> localBoosts = new HashSet(boosted.size()*2);
>         Iterator<String> boostedIt = boosted.iterator();
>         while(boostedIt.hasNext()) {
>           localBoosts.add(new BytesRef(boostedIt.next()));
>         }
>         boostDocs = new IntOpenHashSet(boosted.size()*2);
>         List<AtomicReaderContext>leaves = indexSearcher.getTopReaderContext().leaves();
>         TermsEnum termsEnum = null;
>         DocsEnum docsEnum = null;
>         for(AtomicReaderContext leaf : leaves) {
>           AtomicReader reader = leaf.reader();
>           int docBase = leaf.docBase;
>           Bits liveDocs = reader.getLiveDocs();
>           Terms terms = reader.terms(fieldName);
>           termsEnum = terms.iterator(termsEnum);
>           Iterator<BytesRef> it = localBoosts.iterator();
>           while(it.hasNext()) {
>             BytesRef ref = it.next();
>             if(termsEnum.seekExact(ref)) {
>               docsEnum = termsEnum.docs(liveDocs, docsEnum);
>               int doc = docsEnum.nextDoc();
>               if(doc != -1) {
>                 //Found the document.
>                 boostDocs.add(doc+docBase);
>                *// HERE REMOVE ANY DOCUMENTS THAT SHARE THE GROUPID NOT ONLY THE DOCID //*
>                 it.remove();
>               }
>             }
>           }
>         }
>       }
>       return boostDocs;
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

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