Skip to content

How to "must" : [ { "match" { "foo" : "bar"} } ] #202

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

Closed
mvincent opened this issue Mar 31, 2013 · 2 comments
Closed

How to "must" : [ { "match" { "foo" : "bar"} } ] #202

mvincent opened this issue Mar 31, 2013 · 2 comments

Comments

@mvincent
Copy link

I'm trying to model this request:
(similar to http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/)

curl -XPOST "localhost:9200/index/type/_search?pretty=true" -d '{
"query" : {
  "filtered" : {
      "query" : { "match_all" : {} },
      "filter" : {
          "nested" : {
              "path" : "classification",
              "query" : {
                  "bool" : {
                      "must" : [
                          {
                              "match" : {"classificiation.category" : "foo"}
                          }
                      ]
                  }
              },
              "_cache" : true
          }
      }
  }
  }
}'

but am not sure how to create the "match" in the center. It seems only MatchAll() is available. Here's what I have so far:

var resultNest = client.Search<Type>(s => s
    .Index("index")         
    .Type("type")          
    .Query(q1 => q1
        .Filtered(cs => cs
            .Query(q2 => q2.MatchAll())
            .Filter(f => f
                .Nested(n => n
                    .Path(p => p
                        .Classification)
                    .Query(q3 => q3
                        .Bool(b => b
                            .Must(m => m
                                .MatchAll())   // <-- what I really want: "match" : {"classificiation.category" : "foo"}
                            )
                        )
                    )
                )
            )
        )
   );

Do you have any recommendations?

@Mpdreamz
Copy link
Member

Mpdreamz commented Apr 1, 2013

elasticsearch renamed the text family query to match see the release notes at:

http://www.elasticsearch.org/2012/08/23/0-19-9-released/

The text queries are mapped:

http://nest.azurewebsites.net/query/text.html

and are now backwards aliases for the match queries. I'll add the Match queries to explicitly issue a match query instead of text queries.

Also multi_match support:

elastic/elasticsearch#2153

Leaving this open untill these made it into master.

@benbenwilde
Copy link

This is not documented well at all.
Had to resort to writing my own unit tests and checking the output to figure out how to get the right query out of it.

var serializer = new NestSerializer(new ConnectionSettings());
var json = Encoding.UTF8.GetString(serializer.Serialize(query));
Console.WriteLine(json);

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