Wildcard queryedit

Returns documents that contain terms matching a wildcard pattern.

A wildcard operator is a placeholder that matches one or more characters. For example, the * wildcard operator matches zero or more characters. You can combine wildcard operators with other characters to create a wildcard pattern.

Example requestedit

The following search returns documents where the user field contains a term that begins with ki and ends with y. These matching terms can include kiy, kity, or kimchy.

var searchResponse = client.Search<object>(s => s
    .AllIndices()
    .Query(q => q
        .Wildcard(w => w
            .Field("user")
            .Value("ki*y")
            .Boost(1)
            .Rewrite(MultiTermQueryRewrite.ConstantScore)
        )
    )
);
resp = client.search(
    body={
        "query": {
            "wildcard": {
                "user": {
                    "value": "ki*y",
                    "boost": 1,
                    "rewrite": "constant_score",
                }
            }
        }
    },
)
print(resp)
response = client.search(
  body: {
    query: {
      wildcard: {
        user: {
          value: 'ki*y',
          boost: 1,
          rewrite: 'constant_score'
        }
      }
    }
  }
)
puts response
res, err := es.Search(
	es.Search.WithBody(strings.NewReader(`{
	  "query": {
	    "wildcard": {
	      "user": {
	        "value": "ki*y",
	        "boost": 1.0,
	        "rewrite": "constant_score"
	      }
	    }
	  }
	}`)),
	es.Search.WithPretty(),
)
fmt.Println(res, err)
const response = await client.search({
  body: {
    query: {
      wildcard: {
        user: {
          value: 'ki*y',
          boost: 1,
          rewrite: 'constant_score'
        }
      }
    }
  }
})
console.log(response)
GET /_search
{
    "query": {
        "wildcard": {
            "user": {
                "value": "ki*y",
                "boost": 1.0,
                "rewrite": "constant_score"
            }
        }
    }
}

Top-level parameters for wildcardedit

<field>
(Required, object) Field you wish to search.

Parameters for <field>edit

value

(Required, string) Wildcard pattern for terms you wish to find in the provided <field>.

This parameter supports two wildcard operators:

  • ?, which matches any single character
  • *, which can match zero or more characters, including an empty one

Avoid beginning patterns with * or ?. This can increase the iterations needed to find matching terms and slow search performance.

boost

(Optional, float) Floating point number used to decrease or increase the relevance scores of a query. Defaults to 1.0.

You can use the boost parameter to adjust relevance scores for searches containing two or more queries.

Boost values are relative to the default value of 1.0. A boost value between 0 and 1.0 decreases the relevance score. A value greater than 1.0 increases the relevance score.

rewrite
(Optional, string) Method used to rewrite the query. For valid values and more information, see the rewrite parameter.

Notesedit

Allow expensive queriesedit

Wildcard queries will not be executed if search.allow_expensive_queries is set to false.