Elasticsearch Search API - elasticsearch - elasticsearch tutorial - elastic search
Elasticsearch Search API
- The API is utilized to look content in Elastic pursuit. Either a client can look by sending a get ask for with question string as a parameter or an inquiry in the message assortment of post ask. Chiefly all the inquiry APIS are multi-file, multi-sort.
learn elasticsearch tutorials - search api Example
Multi-Index
- Elastic search allows us to search for the documents present in all the indices or in some specific indices.
- For example, if we need to search all the documents with a name that contains central.
Response
- Or, we can search for the same in schools, schools_gov indices
Multi-Type
- We can also search all the documents in an index across all types or in some specified type. For example,
Response
URI Search
- Many parameters can be passed in a search operation using Uniform Resource Identifier
Sr.No | Parameter & Description |
---|---|
1 | Q This parameter is used to specify query string. |
2 | lenient Format based errors can be ignored by just setting this parameter to true. It is false by default. |
3 | fields This parameter helps us to get response from selective fields. |
4 | sort We can get sorted result by using this parameter, the possible values for this parameter is fieldName, fieldName:asc/fieldname:desc |
5 | timeout We can restrict the search time by using this parameter and response only contains the hits in that specified time. By default, there is no timeout. |
6 | terminate_after We can restrict the response to a specified number of documents for each shard, upon reaching which the query will terminate early. By default, there is no terminate_after. |
7 | from The starting from index of the hits to return. Defaults to 0. |
8 | size It denotes the number of hits to return. Defaults to 10. |
Request Body Search
- We can also specify query using query DSL in request body and there are many examples already given in previous chapters like