hi, in my structure send in my gist, my question is just that:
i have a search field. no say what i type in this field. but i need 1 request like this. { "query" : { "bool": { "must": [ ], "must_not": [ ], "should": [ { "term": { "sku": $datasearch } }, { "term": { "internal_code": $datasearch } }, { "match": { "firstname": $datasearch } }, { "match": { "lastname": $datasearch } }, { "match": { "address": $datasearch } }, { "match": { "city": $datasearch } }, { "match": { "localized_description": $datasearch } }, { "match": { "localized_keywords": $datasearch } }, { "match": { "service.localized_label": $datasearch } }, { "match": { "medias.localized_label": $datasearch } }, { "match": { "services.localized_label": $datasearch } } ] } } }'; Exemple : ------------- - if $datasearch=sku, i have directly 1 user with this sku - if $datasearch=firstname, i have directly a list of user who have this firstname - if $datasearch=keyword, i have list of user who have this keyword - i take term for sku or internal_code because i can't search whith partial of this. (if my sku = 1234, no could found result if i type 123) - And for finish, in my data i have user : [1 - charles martin who have localized_keywords="moto, licorne, cheval, course" ] [2 - henry martin who have localized_keywords="pétanque, chevaux, basket, parieur"] i want with my request have this 2 user if $datasearch = cheval. I hope to be me understand , I can have a bad English thanks Le jeudi 15 janvier 2015 16:17:08 UTC+1, David Pilato a écrit : > > Could you reproduce this with a full test case so we understand exactly > What you are doing? > May be simplify your test. > > See elasticsearch.org/help > > > -- > David ;-) > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs > > Le 15 janv. 2015 à 16:01, Thibaut Owczarz <thi...@1001pharmacies.com > <javascript:>> a écrit : > > i'm ok, but my data search no say if is sku or code_internal or other > field. > > if i do that, it's ok > { > "query": { > "bool": { > "must": [ > { > "term": { > "sku": "01b3ae496c0142f993cf131c607fe003" > } > } > ], > "must_not": [], > "should": [ > { > > "term": { > "internal_code": "01b3ae496c0142f993cf131c607fe003" > } > }, > > { > "match": { > "firstname": "01b3ae496c0142f993cf131c607fe003" > } > }, > { > "match": { > "lastname": "01b3ae496c0142f993cf131c607fe003" > } > }, > { > "match": { > "address": "01b3ae496c0142f993cf131c607fe003" > } > }, > { > "match": { > "city": "01b3ae496c0142f993cf131c607fe003" > } > }, > { > "match": { > "localized_description": "01b3ae496c0142f993cf131c607fe003" > } > }, > { > "match": { > "localized_keywords": "01b3ae496c0142f993cf131c607fe003" > } > }, > { > "match": { > "service.localized_label": "01b3ae496c0142f993cf131c607fe003" > } > }, > { > "match": { > "medias.localized_label": "01b3ae496c0142f993cf131c607fe003" > } > }, > { > "match": { > "services.localized_label": "01b3ae496c0142f993cf131c607fe003" > } > } > ] > } > } > } > > but if now i search with internal_code > { > "query": { > "bool": { > "must": [ > { > "term": { > "sku": "3401598272746" > } > } > ], > "must_not": [], > "should": [ > { > > "term": { > "internal_code": "3401598272746" > > } > }, > > { > "match": { > "firstname": "3401598272746" > } > }, > { > "match": { > "lastname": "3401598272746" > } > }, > { > "match": { > "address": "3401598272746" > } > }, > { > "match": { > "city": "3401598272746" > } > }, > { > "match": { > "localized_description": "3401598272746" > } > }, > { > "match": { > "localized_keywords": "3401598272746" > } > }, > { > "match": { > "service.localized_label": "3401598272746" > } > }, > { > "match": { > "medias.localized_label": "3401598272746" > } > }, > { > "match": { > "services.localized_label": "3401598272746" > } > } > ] > } > } > } > my request is bad > > > Le jeudi 15 janvier 2015 15:49:56 UTC+1, David Pilato a écrit : >> >> I guess it's most likely because you added all your filters in should >> clause instead of must? >> >> -- >> David ;-) >> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs >> >> Le 15 janv. 2015 à 15:36, Thibaut Owczarz <thi...@1001pharmacies.com> a >> écrit : >> >> i found my first error, no need user. because i search already in user. >> but why when i search a defined sku, no found only one ? >> >> >> curl -XPOST 'http://localhost:9200/test_fr/user/_search' -d '{ >> "query" : { >> "bool": { >> "must": [ ], >> "must_not": [ ], >> "should": [ >> { >> "term": { >> "sku": "01b3ae496c0142f993cf131c607fe003" >> } >> }, >> { >> "term": { >> "internal_code": "01b3ae496c0142f993cf131c607fe003" >> } >> }, >> { >> "match": { >> "firstname": "01b3ae496c0142f993cf131c607fe003" >> } >> }, >> { >> "match": { >> "lastname": "01b3ae496c0142f993cf131c607fe003" >> } >> }, >> { >> "match": { >> "address": "01b3ae496c0142f993cf131c607fe003" >> } >> }, >> { >> "match": { >> "city": "01b3ae496c0142f993cf131c607fe003" >> } >> }, >> { >> "match": { >> "localized_description": >> "01b3ae496c0142f993cf131c607fe003" >> } >> }, >> { >> "match": { >> "localized_keywords": >> "01b3ae496c0142f993cf131c607fe003" >> } >> }, >> { >> "match": { >> "service.localized_label": >> "01b3ae496c0142f993cf131c607fe003" >> } >> }, >> { >> "match": { >> "medias.localized_label": >> "01b3ae496c0142f993cf131c607fe003" >> } >> }, >> { >> "match": { >> "services.localized_label": >> "01b3ae496c0142f993cf131c607fe003" >> } >> } >> ] >> } >> } >> }'; >> >> they return all my users. >> >> Thanks >> >> Le jeudi 15 janvier 2015 14:58:16 UTC+1, Thibaut Owczarz a écrit : >>> >>> Hello, >>> I start learning Elasticsearch, and i have a problem for understand how >>> search. anyone could help me? >>> >>> My gist for all my structure and my data is here >>> https://gist.github.com/thibaut1001/7a3000c3ff371be3a52d >>> >>> My problem is just in 4part >>> To search in multi field by data like this >>> >>> >>> ## We need to search henry in field selected >>> curl -XPOST 'http://localhost:9200/test_fr/user/_search' -d '{ >>> "query" : { >>> "bool": { >>> "must": [ ], >>> "must_not": [ ], >>> "should": [ >>> { >>> "term": { >>> "user.sku": "henry" >>> } >>> }, >>> { >>> "term": { >>> "user.internal_code": "henry" >>> } >>> }, >>> { >>> "term": { >>> "user.firstname": "henry" >>> } >>> }, >>> { >>> "term": { >>> "user.lastname": "henry" >>> } >>> }, >>> { >>> "term": { >>> "user.address": "henry" >>> } >>> }, >>> { >>> "term": { >>> "user.city": "henry" >>> } >>> }, >>> { >>> "term": { >>> "user.localized_description": "henry" >>> } >>> }, >>> { >>> "term": { >>> "user.localized_keywords": "henry" >>> } >>> }, >>> { >>> "term": { >>> "user.service.localized_label": "henry" >>> } >>> }, >>> { >>> "term": { >>> "user.medias.localized_label": "henry" >>> } >>> }, >>> { >>> "term": { >>> "user.services.localized_label": "henry" >>> } >>> } >>> ] >>> } >>> } >>> }'; >>> >>> ## Return no results Why? >>> >>> I have many question. >>> Could you help me please, >>> thanks >>> >>> -- >> 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 elasticsearc...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/elasticsearch/2ced6dc5-fa42-43bd-81bf-99ce4f7bedb5%40googlegroups.com >> >> <https://groups.google.com/d/msgid/elasticsearch/2ced6dc5-fa42-43bd-81bf-99ce4f7bedb5%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 elasticsearc...@googlegroups.com <javascript:>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elasticsearch/ada83459-b492-4cff-b0e6-b574b7a47359%40googlegroups.com > > <https://groups.google.com/d/msgid/elasticsearch/ada83459-b492-4cff-b0e6-b574b7a47359%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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/13445ad0-a7fd-4c2b-b154-7863a61a469a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.