lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [lucenenet] jregnier commented on issue #324: Exclude query help
Date Fri, 07 Aug 2020 20:23:19 GMT

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



Mime
View raw message