MultiPhraseQuery in Elastic using NEST

Hi,
I'm migrating from Lucene to Elastic (6.2.4).

Today we use Lucene's MultiPhraseQuery to set phrase queries in the same position. Elastic (and NEST) comes with a "MatchPhrase" query that can get only one phrase (string). There is an equivalent to MultiPhraseQuery as well?

It looks like Lucene's MultiPhraseQuery maps to Elasticsearch's Match Phrase Prefix query, with prefix matches on the last term.

@forloop, thank you for your response.
I don't think MultiPhraseQuery (lucene) is equivalent to Match Phrase Prefix query (elastic).

MultiPhraseQuery is "A generalized version of PhraseQuery, with the possibility of adding more than one term at the same position that are treated as a disjunction (OR)."

While Match Phrase Prefix query is "The match_phrase_prefix is the same as match_phrase, except that it allows for prefix matches on the last term in the text"

It is true that you can use both for some functionality, but it is not the same.
The main feature for MultiPhraseQuery is the fact that both terms are in the same position.

Thanks

Gotcha!

It looks like MultiPhrseQuery is not exposed in the REST API of Elasticsearch; it's used internally in a few places but no exposed.

You should however be able to achieve similar functionality with span_near and nested span_or queries

Thank you. span or is similar but with some main differences:
1 - Performance is not as fast as MultiPhrseQuery
2 - it calculates scoring differently (not dismax, but sum like bool query)

There is a way to expose it in the next version or with a patch?
This is a powerful MultiPhrseQuery type in lucene.

Thanks!

I would recommend opening a new issue on the Elasticsearch repository first to discuss with folks from Elasticsearch core team.

Thank you!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.