almogtavor commented on issue #12406: URL: https://github.com/apache/lucene/issues/12406#issuecomment-1627194434
@mikemccand maybe you've got an idea? <details> <summary>I tried to follow the instructions that I saw in your blog and produced code as follows:</summary> ```java @Override public void run(ApplicationArguments args) throws Exception { MonitorConfiguration monitorConfig = new MonitorConfiguration(); Monitor monitor = new Monitor(new StandardAnalyzer(), new TermFilteredPresearcher(), monitorConfig); registerQueries(monitor); // Creating a parent document with child documents Document parentDoc = new Document(); parentDoc.add(new StringField("id", "shirt1", Field.Store.YES)); parentDoc.add(new StringField("name", "wolf", Field.Store.YES)); parentDoc.add(new StringField("type", "shirt", Field.Store.YES)); // Creating child documents (SKUs) Document childDoc1 = new Document(); childDoc1.add(new StringField("size", "small", Field.Store.YES)); childDoc1.add(new StringField("color", "blue", Field.Store.YES)); Document childDoc2 = new Document(); childDoc2.add(new StringField("size", "medium", Field.Store.YES)); childDoc2.add(new StringField("color", "black", Field.Store.YES)); Document[] documents = {parentDoc,childDoc1,childDoc2}; MultiMatchingQueries<HighlightsMatch> hm = monitor.match(documents, HighlightsMatch.MATCHER); log.info("Got " + hm.getMatchCount(0) + " matches"); hm.getMatches(0).forEach(m -> { log.info("Match: " + m.getQueryId() + " with " + m.getHitCount()); m.getHits("name").forEach(h -> { log.info(" hit: " + h.toString() + " - " + parentDoc.get("name").substring(h.startOffset, h.endOffset)); }); }); } private void registerQueries(Monitor monitor) throws IOException, ParseException { MonitorQuery monitorQuery1 = newMonitorQuery("ShirtQuery1", "name:wolf AND size:small AND color:blue", Collections.singletonMap("customer", "123")); MonitorQuery monitorQuery2 = newMonitorQuery("ShirtQuery2", "name:wolf AND size:medium AND color:black", Collections.singletonMap("customer", "124")); monitor.register(monitorQuery1); monitor.register(monitorQuery2); } private MonitorQuery newMonitorQuery(String id, String queryString, Map<String, String> metadata) throws ParseException { QueryParser qp = new QueryParser("name", new StandardAnalyzer()); Query shirtQuery = qp.parse(queryString.split(" AND ")[0]); QueryParser qpChild = new QueryParser("size", new StandardAnalyzer()); Query sizeQuery = qpChild.parse(queryString.split(" AND ")[1]); qpChild = new QueryParser("color", new StandardAnalyzer()); Query colorQuery = qpChild.parse(queryString.split(" AND ")[2]); BooleanQuery childQuery = new BooleanQuery.Builder() .add(sizeQuery, BooleanClause.Occur.MUST) .add(colorQuery, BooleanClause.Occur.MUST) .build(); // Construct ToParentBlockJoinQuery from child query BitSetProducer parentFilter = new QueryBitSetProducer(new TermQuery(new Term("type", "shirt"))); ToParentBlockJoinQuery parentJoinQuery = new ToParentBlockJoinQuery(childQuery, parentFilter, ScoreMode.None); BooleanQuery finalQuery = new BooleanQuery.Builder() .add(shirtQuery, BooleanClause.Occur.MUST) .add(parentJoinQuery, BooleanClause.Occur.MUST) .build(); log.info("Registered monitor query " + id); return new MonitorQuery(id, finalQuery, queryString, metadata); } ``` </details> But it still wouldn't match. -- 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. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org