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

How can I set type "cross-fields" in MultiMatchQuery ? #82

Open
antoineberthelin opened this issue Nov 28, 2014 · 3 comments
Open

How can I set type "cross-fields" in MultiMatchQuery ? #82

antoineberthelin opened this issue Nov 28, 2014 · 3 comments

Comments

@antoineberthelin
Copy link

Hello,

I try to set "cross-fields" in MultiMatchQuery

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#type-cross-fields

I don't find this parameter, do you know if it's possible to set it ?

Thanks,

Antoine

@ajcarpenter
Copy link

You should be able to set this via the type method, but for some reason, elastic.js restricts this to only have the values of boolean, phrase or phrase_prefix (https://github.com/fullscale/elastic.js/blob/master/src/query/MultiMatchQuery.js#L283). If I remove this validation, I am able to successfully run a cross-fields search. ElasticSearch docs say valid values include best_fields, most_fields, cross_fields, phrase, phrase_prefix. I would guess that this was changed at some point and elastic.js hasn't been updated to match. I will try and submit a pull request for this.

@ajcarpenter
Copy link

As a hack, you can trick elastic.js in to thinking you're passing in a query object by giving it something like:

{
    _type: function () { return 'query'; },
    toJSON: function () { return {multi_match: this.multi_match}; },
    multi_match: { 
        query: queryParams.query,
        fields: [ 'artist_name', 'title' ],
        zero_terms_query: 'all',
        type: 'cross_fields',
        operator: 'and' 
    } 
}

@ajcarpenter
Copy link

Looks like there is already a PR to fix this: #84

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

2 participants