简体   繁体   中英

How to get all documents in elasticsearch index using “*” in simple_query_string

I am passing the * into the query to fetch all fields in index using the simple_query_string script, but it returns only an empty result. Kindly guide me to solve this situation. The formed query is:

{"query":{"simple_query_string":{"query":"*","fields":["_all"]}},"from":0,"size":5}

The answer to your question is found in the docs :

* at the end of a term signifies a prefix query

* is not a regular wildcard. You can only use it at the end of a token, eg exampl* matches exampleword

If you want to get all available documents there's a dedicated query for that :

{ "match_all": {} }

For wildcard style match you would use :

{ "wildcard" : { "user" : "ki*y" } }

Check more info on wildcard queries here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM