Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How to query programmatically #12

Open
reckart opened this issue Dec 7, 2021 · 0 comments
Open

Question: How to query programmatically #12

reckart opened this issue Dec 7, 2021 · 0 comments

Comments

@reckart
Copy link
Contributor

reckart commented Dec 7, 2021

The code we are currently using in INCEpTION to perform an MTAS search looks pretty complicated - but I am pretty sure that is the way we were told that querying MTAS would work:

    private static void doQuery(IndexReader indexReader, String field, MtasSpanQuery q,
            List<String> prefixes)
        throws IOException
    {
        ListIterator<LeafReaderContext> iterator = indexReader.leaves().listIterator();
        IndexSearcher searcher = new IndexSearcher(indexReader);
        final float boost = 0;
        SpanWeight spanweight = q.rewrite(indexReader).createWeight(searcher, false, boost);

        while (iterator.hasNext()) {
            LeafReaderContext lrc = iterator.next();
            Spans spans = spanweight.getSpans(lrc, SpanWeight.Postings.POSITIONS);
            SegmentReader segmentReader = (SegmentReader) lrc.reader();
            Terms terms = segmentReader.terms(field);
            CodecInfo mtasCodecInfo = CodecInfo.getCodecInfoFromTerms(terms);
            if (spans != null) {
                while (spans.nextDoc() != Spans.NO_MORE_DOCS) {
                ...

But normally, querying lucene would use something like searcher.query(q, myCollector) - and there are also search signatures which would e.g. allow for sorting results etc. So I was wondering (I haven't tried it yet): can the search/collector approach really not be used with MTAS? If not, why? And if it can be used, does anybody have an example for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant