Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryBuilder not generating the right match query #796

Closed
BitOne opened this issue Mar 10, 2015 · 2 comments
Closed

QueryBuilder not generating the right match query #796

BitOne opened this issue Mar 10, 2015 · 2 comments

Comments

@BitOne
Copy link

BitOne commented Mar 10, 2015

Hello,

It seems that the QueryBuilder, when asked to generate a match() query, doesn't generate the right DSL.

query->setQuery(
    $qb->query()->match("description", "processor");
);

will generate the following Elasticsearch JSON:

{
    "query":{
        "match":{
            "field": {
                "description-en_US-print":"processor"
            }
        }
    }
}

Which is the wrong syntax, as the match query should be:

{
    "query":{
        "match":{
            "description-en_US-print":"processor"
        }
    }
}

as defined here: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-match-query.html#query-dsl-match-query

The problem seems to come from the QueryBuilder code:
https://github.com/ruflin/Elastica/blob/master/lib/Elastica/QueryBuilder/DSL/Query.php#L67

When replacing the following line:

$match->setFieldParam('field', $field, $value);

by

$match->setParam($field, $value);

the resulting syntax is correct and the query works well.

What do you think guys ? Is there something I'm doing wrongly or there's a problem with the QueryBuilder DSL Query part for the match query ?

Thanks !

@ruflin
Copy link
Owner

ruflin commented Mar 12, 2015

@webdevsHub Can you have a look here?

webdevsHub added a commit to webdevsHub/Elastica that referenced this issue Mar 12, 2015
webdevsHub added a commit to webdevsHub/Elastica that referenced this issue Mar 12, 2015
@webdevsHub
Copy link
Contributor

definitely a bug! plx see #798

thx for reporting @BitOne

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants