You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by GitBox <gi...@apache.org> on 2020/08/07 19:52:18 UTC

[GitHub] [lucenenet] jregnier opened a new issue #324: Exclude query help

jregnier opened a new issue #324:
URL: https://github.com/apache/lucenenet/issues/324


   Hey guys, wondering if I could get a hand with a query I'm struggling with. My index is structured with a parent-child relationship. When I do a search I look at the child documents and then load the parent document associated with it. So my issue is that when I do an exclude I get documents I don't want back. For example, for a given parent, if one child is "lucene is awesome" and another child document is "lucene is great", then if I search for "+lucene -great" I still get the parent since it hit on the first child which makes sense but is there a way to filter out the parent that has 1 child document that fails the criteria?
   
   thanks


----------------------------------------------------------------
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



[GitHub] [lucenenet] rclabo commented on issue #324: Exclude query help

Posted by GitBox <gi...@apache.org>.
rclabo commented on issue #324:
URL: https://github.com/apache/lucenenet/issues/324#issuecomment-670718913


   Thanks that helpful and answers the questions I raised.  Unfortunately several methods being used are ones that I don't have experience with and the code is too psudo codish for me to easily repo the issue and work towards a solution.  So I'm gonna hope that someone with more experience than I jumps in to help.


----------------------------------------------------------------
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



[GitHub] [lucenenet] jregnier commented on issue #324: Exclude query help

Posted by GitBox <gi...@apache.org>.
jregnier commented on issue #324:
URL: https://github.com/apache/lucenenet/issues/324#issuecomment-671398005


   So I ended up figuring it out, turns out you can combine 2 ToParentBlockJoinQuery into a BooleanQuery so I just added an exclude query and voila. Thanks for the help


----------------------------------------------------------------
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



[GitHub] [lucenenet] jregnier commented on issue #324: Exclude query help

Posted by GitBox <gi...@apache.org>.
jregnier commented on issue #324:
URL: https://github.com/apache/lucenenet/issues/324#issuecomment-670698083


   thanks for the response, see below 
   
   `analyzer uses a chartokenizer with a lowercase filter
   
   var dir = FSDirectory.Open(indexFolderPath);
   var indexConfig = new IndexWriterConfig(LuceneVersion.LUCENE_48, {analyzer});
   _writer = new IndexWriter(dir, indexConfig);
   
   var parentDocument = new Document();
   parentDocument.Add({BinaryDocValuesField});
   parentDocument.Add({StringField});
   parentDocument.Add({StringField});
   parentDocument.Add({StringField});
   
   var childDocument = new Document();
   childDocument.Add({StringField});
   childDocument.Add({StringField});
   childDocument.Add({TextField}) // not stored;
   childDocument.Add({StringField}) // only some documents will have this;
   
   // we are creating a parent child relationship with this list of documents
   _writer.AddDocuments(documentList)
   
   _reader = DirectoryReader.Open(FSDirectory.Open(indexFolderPath));
   _searcher = new IndexSearcher(_reader);
   BooleanQuery.MaxClauseCount = int.MaxValue;
   
   var searchString = "value:test search string"
   var terms = new SpanMultiTermQueryWrapper(new WildcardQuery(new Term(fieldName, word)) // terms is a list of these for each word
   var childQuery = new SpanNearQuery(terms, 0, true)
   
   var parentFilter = new FixedBitSetCachingWrapperFilter(
      new QueryWrapperFilter(
         new TermQuery(
            new Term(fieldName, value))));
   
   var query = ToParentBlockJoinQuery(childQuery, parentFilter, ScoreMode.Max);
   
   var sort = new Sort(new SortField(null, SortFieldType.DOC));
   return _searcher.Search(query, _reader.NumDocs, sort)`


----------------------------------------------------------------
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



[GitHub] [lucenenet] jregnier closed issue #324: Exclude query help

Posted by GitBox <gi...@apache.org>.
jregnier closed issue #324:
URL: https://github.com/apache/lucenenet/issues/324


   


----------------------------------------------------------------
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



[GitHub] [lucenenet] rclabo commented on issue #324: Exclude query help

Posted by GitBox <gi...@apache.org>.
rclabo commented on issue #324:
URL: https://github.com/apache/lucenenet/issues/324#issuecomment-670690698


   Can you provide more detail on how you implemented your  parent child relationship?  Also when you do a search on the child documents, how are you then loading the parent document associated with each child?  Finally, what version of Lucene.Net are you using?


----------------------------------------------------------------
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