0

I am trying to do query like this:

Gym.search({
                    "query" : {
                        "multi_match": {
                            "fields": ["multi_field"],
                            "query": req.query.q,
                            "fuzziness": "AUTO"
                        }
                    }
                },
                function (err, results) {
                    if (err) {
                        return console.log(JSON.stringify(err, null, 4));
                    }
                    return console.log(JSON.stringify(results, null, 4));
                });

But it returns:

"status": 400, "displayName": "BadRequest", "message": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[PzLsLPHfTMu68AQ94_Af8g][gyms][0]: SearchParseException[[gyms][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"query\":{\"multi_match\":{\"fields\":[\"multi_field\"],\"query\":\"LCC\",\"fuzziness\":\"AUTO\"}}}}]]]; nested: QueryParsingException[[gyms] No query registered for [query]]; }{[PzLsLPHfTMu68AQ94_Af8g][gyms][1]: SearchParseException[[gyms][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"query\":{\"multi_match\":{\"fields\":[\"multi_field\"],\"query\":\"LCC\",\"fuzziness\":\"AUTO\"}}}}]]]; nested: QueryParsingException[[gyms] No query registered for [query]]; }{[PzLsLPHfTMu68AQ94_Af8g][gyms][2]: SearchParseException[[gyms][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"query\":{\"multi_match\":{\"fields\":[\"multi_field\"],\"query\":\"LCC\",\"fuzziness\":\"AUTO\"}}}}]]]; nested: QueryParsingException[[gyms] No query registered for [query]]; }{[PzLsLPHfTMu68AQ94_Af8g][gyms][3]: SearchParseException[[gyms][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"query\":{\"multi_match\":{\"fields\":[\"multi_field\"],\"query\":\"LCC\",\"fuzziness\":\"AUTO\"}}}}]]]; nested: QueryParsingException[[gyms] No query registered for [query]]; }{[PzLsLPHfTMu68AQ94_Af8g][gyms][4]: SearchParseException[[gyms][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"query\":{\"multi_match\":{\"fields\":[\"multi_field\"],\"query\":\"LCC\",\"fuzziness\":\"AUTO\"}}}}]]]; nested: QueryParsingException[[gyms] No query registered for [query]]; }]"

It works when I use CURL... Anyone know how to fix it?

1 Answer 1

1

Try like this:

 Gym.search({
                "multi_match": {
                    "fields": ["multi_field"],
                    "query": req.query.q,
                    "fuzziness": "AUTO"
                }
            },
            function (err, results) {
                if (err) {
                    return console.log(JSON.stringify(err, null, 4));
                }
                return console.log(JSON.stringify(results, null, 4));
            });
Sign up to request clarification or add additional context in comments.

1 Comment

I need your help with this :'( stackoverflow.com/questions/37878490/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.