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

Support for nested queries #13

Open
gregsilin opened this issue May 29, 2019 · 4 comments
Open

Support for nested queries #13

gregsilin opened this issue May 29, 2019 · 4 comments

Comments

@gregsilin
Copy link

Thanks for making this library possible!

I'm using it for a project that requries supporting multi-word typeahead sort of query.

Example text:

Mary had a little lamb

Queries such as Mar*, Mary ha*, Mary had a litt*, Mary had a little la* all should match. Fuzzy match not required.

After running into a lot of all dead ends, the approach that I found that worked for me is the one mentioned in this SO article.

public static Query createPhraseQuery(String[] phraseWords, String field) {
    SpanQuery[] queryParts = new SpanQuery[phraseWords.length];
    for (int i = 0; i < phraseWords.length; i++) {
        WildcardQuery wildQuery = new WildcardQuery(new Term(field, phraseWords[i]));
        queryParts[i] = new SpanMultiTermQueryWrapper<WildcardQuery>(wildQuery);
    }
    return new SpanNearQuery(queryParts,       //words
                             0,                //max distance
                             true              //exact order
    );
}

I'd like to contribute a PR to enable SpanQuery support.

What is your requirement for opening PRs, and do you have a preferred approach for handling nested queries? I am asking as I want to keep code consistent with your vision / style (and to limit PR re-works :D).

PR Happy to hear alternative proposals on my original quest - I didn't really find much success with phrase queries or wildcard queries once I went to multiple words with partial match.

@darkfrog26
Copy link
Contributor

I'd welcome a PR. I'd prefer the code style remain consistent, and I might offer some feedback, but I don't hold any hard and fast rules.

@darkfrog26
Copy link
Contributor

@gregsilin, is this something you're still interested in?

@gregsilin
Copy link
Author

gregsilin commented Aug 28, 2019

Hi, yes we would love this! We have a private fork of the above (our company code is not on GitHub) but I haven’t had the chance to open a PR. I can at the very least share the changes.

I’ll try to find time to open a PR in the next couple of weeks

@darkfrog26
Copy link
Contributor

That sounds great. If you haven't noticed, I've been making significant changes and improvements to this project and intend a 1.9 release tomorrow. It doesn't sound like you'll have a PR in time for that, but I'll try to merge and do a new release as soon as you can get me the PR. If you have any other changes, feel free to share them. Lucene is a pain to use, so any assistance is always welcome. ;)

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

2 participants