Complex query

Hello community,
First, I apologize for my English.

I can not find a complex query.
I have thes columns :
Id : String
Name : String
FirstName : String
ZipCode : String

If a user perfoms a query : "*word1 *.... wordn"
I need to make a query, something like this :

Name contains word1 OR
FirstName contains word1 OR
ZipCode starts with word1
AND
....
AND
Name contains wordn OR
FirstName contains wordn OR
ZipCode starts with wordn

i make this query but it's not my real need :

{

  • "query": {*
  • "bool": {*
  •  "must": [*
    
  •    {*
    
  •      "query_string": {*
    
  •        "fields": [*
    
  •          "name",*
    
  •          "firstname",*
    
  •          "zipcode"*
    
  •        ],*
    
  •        "query": "*word1*"*
    
  •      }*
    
  •    },*
    
  •    {*
    
  •      "query_string": {*
    
  •        "fields": [*
    
  •          "name",*
    
  •          "firstname",*
    
  •          "zipcode"*
    
  •        ],*
    
  •        "query": "*wordn*"*
    
  •      }*
    
  •    }*
    
  •  ],*
    
  •  "must_not": [],*
    
  •  "should": []*
    
  • }*
  • },*
  • "from": 0,*
  • "size": 10,*
  • "sort": [],*
  • "facets": {}*
    *} *

This query is not good because I don't have my condition "zipcode start
with" but "zipcode contains".

Can someone help me build the right query ?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/882034da-08c4-4573-ac1a-c3d929ca1154%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Please, I really need help for this query.

I just created this query but it's a very heavy query

{
"query": {
"match_all": {}
},
"filter": {
"and": [
{
"or": [
{
"query": {
"query_string": {
"query": "Word1",
"default_field": "name"
}
}
},
{
"query": {
"query_string": {
"query": "Word1",
"default_field": "firstname"
}
}
},
{
"query": {
"query_string": {
"query": "Word1*",
"default_field": "zipcode"
}
}
}
]
},
{
"or": [
{
"query": {
"query_string": {
"query": "Wordn",
"default_field": "name"
}
}
},
{
"query": {
"query_string": {
"query": "Wordn",
"default_field": "firstname"
}
}
},
{
"query": {
"query_string": {
"query": "Wordn*",
"default_field": "zipcode"
}
}
}
]
}
]
}
}

If i have ten word, i think the query will be very very very long to be
execute

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/29359521-cada-41de-beac-1b6d786abbdd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hello,

Nobody can help me to find a solution for this query ?

I really need help plz.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/20f5fa82-0e18-45cf-babd-70a00fbb4e6d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I haven't had time to look at your query, but have you looked into
multi-field queries?

--
Ivan

On Mon, May 19, 2014 at 12:56 AM, ElasticRookie farhat.bakiri@gmail.comwrote:

Hello,

Nobody can help me to find a solution for this query ?

I really need help plz.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/20f5fa82-0e18-45cf-babd-70a00fbb4e6d%40googlegroups.comhttps://groups.google.com/d/msgid/elasticsearch/20f5fa82-0e18-45cf-babd-70a00fbb4e6d%40googlegroups.com?utm_medium=email&utm_source=footer
.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCHhe4M%2BTwrWc2x1VUbNweSWr_%2BrzTNyFEG3rY3MULGkg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

maybe its simpler to make it in just one query_string like this:

curl 'http://127.0.0.1:9200/data/_search' --data
'{"fields":["parent","source"],"query":{"bool":{"must": [ {
"simple_query_string": { "query": "
(a|b*) c (x|y)
",
"default_operator": "AND" } }
]}},"from":0,"size":10,"sort":,"facets":{},"version":true}'

query_string allows really powerful expressions

Am 16.05.2014 15:22, schrieb ElasticRookie:

Hello community,
First, I apologize for my English.

I can not find a complex query.
I have thes columns :
Id : String
Name : String
FirstName : String
ZipCode : String

If a user perfoms a query : "*word1 *.... wordn"
I need to make a query, something like this :

Name contains word1 OR
FirstName contains word1 OR
ZipCode starts with word1
AND
....
AND
Name contains wordn OR
FirstName contains wordn OR
ZipCode starts with wordn

i make this query but it's not my real need :

/{/
/ "query": {/
/ "bool": {/
/ "must": [/
/ {/
/ "query_string": {/
/ "fields": [/
/ "name",/
/ "firstname",/
/ "zipcode"/
/ ],/
/ "query": "word1"/
/ }/
/ },/
/ {/
/ "query_string": {/
/ "fields": [/
/ "name",/
/ "firstname",/
/ "zipcode"/
/ ],/
/ "query": "wordn"/
/ }/
/ }/
/ ],/
/ "must_not": ,/
/ "should": /
/ }/
/ },/
/ "from": 0,/
/ "size": 10,/
/ "sort": ,/
/ "facets": {}/
/} /

This query is not good because I don't have my condition "zipcode
start with" but "zipcode contains".

Can someone help me build the right query ?

You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to elasticsearch+unsubscribe@googlegroups.com
mailto:elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/882034da-08c4-4573-ac1a-c3d929ca1154%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/882034da-08c4-4573-ac1a-c3d929ca1154%40googlegroups.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/537B7AB1.2010702%40gmail.com.
For more options, visit https://groups.google.com/d/optout.