0
{
            "_index": "shiv",
            "_type": "bomsankar",
            "_id": "AU6xh_h_1wCutPkm0XxN",
            "_score": 68.16099,
            "_source": {
                "grp_id": 45110,
                "img": "http://media.text.com/0/0/0/724/bc5ab3ff-6068-4cfd-9605-e6f62dfddd4f.png?originalFormat=tif&tkn=914dad50-013c-11e4-acaa-005056ab571e&size=50x50",
                "upc14": "00851087000571",
                "upc12": "851087000571",
                "brand": "Peanut Butter & Co.",
                "name": "Peanut Butter & Co. All Natural Mighty Fine Chocolate Peanut Butter Cupcakes Baking Mix",
                "Len": "20",
                "description": "All Natural Mighty Fine Chocolate Peanut Butter Cupcakes Baking Mix"
            }
        },
        {
            "_index": "shiv",
            "_type": "bomsankar",
            "_id": "AU6w_WVy1wCutPkm0WJY",
            "_score": 62.595284,
            "_source": {
                "grp_id": 36866,
                "img": "http://media.text.com/0/0/0/117/7465e6fb-c11c-4a54-8423-d9de0f66e080.png?originalFormat=tif&tkn=914dad50-013c-11e4-acaa-005056ab571e&size=50x50",
                "upc14": "00851087000069",
                "upc12": "851087000069",
                "brand": "Peanut Butter & Co.",
                "name": "All Natural Peanut Butter & Co. Dark Chocolate Dreams",
                "Len": "20",
                "description": "utter & Co. Dark Chocolate Dreams"
            }
        },
        {
            "_index": "shiv",
            "_type": "bomsankar",
            "_id": "AU6xeGi-1wCutPkm0XlU",
            "_score": 62.595284,
            "_source": {
                "grp_id": 44166,
                "img": "http://media.text.com/0/0/0/490/3344ba7c-463d-47b8-9677-309fe513c11e.png?originalFormat=tif&tkn=914dad50-013c-11e4-acaa-005056ab571e&size=50x50",
                "upc14": "00851087000052",
                "upc12": "851087000052",
                "brand": "Peanut Butter & Co.",
                "name": "All Natural Peanut Butter & Co. White Chocolate Wonderful",
                "Len": "20",
                "description": "utter & Co. White Chocolate Wonderful"
            }
        },
        {
            "_index": "shiv",
            "_type": "bomsankar",
            "_id": "1370",
            "_score": 33.893097,
            "_source": {
                "grp_id": 1372,
                "img": "http://media.text.com/0/0/0/58/85dfa93d-53e8-443f-9008-44994ea14a3e.png?originalFormat=tif&tkn=914dad50-013c-11e4-acaa-005056ab571e&size=50x50",
                "upc14": "00688267077128",
                "upc12": "688267077128",
                "brand": "Ahold",
                "name": "Ahold Peanut Butter Chunky",
                "Len": "6",
                "description": "Peanut Butter Chunky"
            }
        }

I am using elasticsearch to search data from json fields. I am getting problem to search some phrase from the above json. I am searching for "Peanut B%" from name and brand fields. What will be the query?

RITESH NAG
  • 53
  • 1
  • 3
  • 8
  • What did you try ? What problems are you running into ? – xlecoustillier Jul 22 '15 at 07:57
  • `curl -X GET "http://b427046-1.aws.found.io:9200/shiv/bomsankar/_search?preety" -d '{"query":{"bool":{"should":[{"match_phrase_prefix":{"brand":"peanut b"}},{"match_phrase_prefix":{"name":"peanut b"}}]}}}'` I am writing this query it's working fine if I put the search value "peanut" or "peanut butter" but not getting any result if i put "peanut b". I need to search with like query. I need value with like query. ex. "peanut b%" – RITESH NAG Jul 22 '15 at 08:53
  • Check your mappings: `curl -X GET "http://b427046-1.aws.found.io:9200/shiv/bomsankar/_mappings`. You should index your data using a `completion` type so that ES is able to return suggestions. Check this documentation page: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html – Mihai Ionescu Jan 14 '16 at 10:06

0 Answers0