ElasticSearch Part 4 [Advanced Query]

lets focus in the Query string what we can achieve and how we can perform advanced queries using the query string

1. +/- Operators: This helps us to filter the words during the search. Let us take an example:
GET /ecommerce/product/_search?q=(name:(+dell)
in the above query the name feild must contain the dell word

GET /ecommerce/product/_search?q=(name:(+dell -hp))
in the above query the name field must contain the dell word and must not contain any hp word

2. Boolean Operators:: lets say we want to search the product with
  - name as "dell"
  - must have status active i.e. 1
  - which description must contain the word "code"

so we will do it by
GET /ecommerce/product/_search?q=(name:(+dell -hp) AND status:1 AND description:+code)


0 comments:

Post a Comment