My object looks like this
{
"country_id":3,
"user_id":22,
"name": "John",
"surname": "Wright",
"city_name":"Sydney",
}
I want to do this:
SELECT * FROM STUDENT WHERE user_id= :1 AND country_id= :2
AND LOWER(name) LIKE '%' || :3 || '%'
OR LOWER(surname) LIKE '%' || :4 || '%'
OR LOWER(city_name) LIKE '%' || :5 || '%'
OFFSET :6 ROWS FETCH NEXT :7 ROWS ONLY
I tried the following:
curl -XPOST "http://xxx.xxx.xxx.x:9200/xxxx/students/_search" -d '{
"from": 6, "size": 11,
"query": {
"bool": {
"must": [
{
"term": {
"country_id": "123"
},
{
"term": {
"user_id": "abc35"
}
},
{
"query_string": {
"query": "name:*abc*",
"query": "surname:*abc*",
"query": "city_name:*abc*",
}
}
]
}
}
}
User's search string will be applied on fields name, surname, city_name etc.
Can someone please point out what I'm missing? I want the smallest possible query as there can be multiple fields to be passed in query strings for user's search query to be applied on (like school_name, hobbies, education).
wildcardfield type instead is more beneficial for your use case.