Elasticsearch Term Level Queries – Prefix Query & Wildcard Query

In this tutorial, we’re gonna look at how to use Elasticsearch Prefix Query & Wildcard Query.

I. Prefix Query

prefix query matches documents that have fields containing terms with a specified prefix (not analyzed).

For example, find customers where fullname contains a term that starts with “ja”:

Response:

Boost

boost parameter can give term query a higher relevance score than another query.
The default boost value is 1.

Response with the _score has changed:

II. Wildcard Query

wildcard query matches documents that have fields matching a wildcard expression (not analyzed).
Supported wildcards:
*: matches any character sequence (including the empty one)
?: matches any single character

For example:

Response:

*Note: This query can be slow (iterate over many terms). So a wildcard term should not start with * or ?.

Boost

boost parameter can give term query a higher relevance score than another query.
The default boost value is 1.

By JavaSampleApproach | November 6, 2017.

Related Posts


Got Something To Say:

Your email address will not be published. Required fields are marked *

*