[match] query does not support [type]

Hey all,

After upgrading to a new cluster running Elasticsearch 6.0, from a cluster running 5.4, I'm running into a persistent 400 Error with the message when attempting to run my previously-working Query on the new cluster:

parsing_exception Reason: [match] query does not support [type]

I've attempted to add the lenient flag to all of my Match queries, but it has made no difference. Any insight?

Have you read their post about Removal of mapping types?

This may or may not be helpful :frowning:

I'm only storing one type of document per index, so it's not completely applicable.

Sure. Are you able to post the query here? And perhaps the mapping of the index?

1 Like

Here's the query:

          .Query(q  => q
            .Bool( b => b
                .Should(s => s
                    .MatchPhrase(m => m
                        .Query(searchTerm)
                        .Field(fi => fi.Items.First().Id)
                        .Lenient(true)),                           
                    s => s
                    .Match(m =>m
                        .Query(date)
                        .Field(fi => fi.CustomAttributes["Expiration"])
                        .Lenient(true)),
                    s => s
                    .Fuzzy(f => f
                        .Value(searchTerm)
                        .Field(fi => fi.Items.First().Cat)
                        ),
                    s => s
                    .MatchPhrase(c => c
                        .Query(searchTerm)
                        .Field(fi => fi.Name)
                        .Analyzer("synonym_analyzer")
                        .Fuzziness(Fuzziness.EditDistance(2))
                        .Lenient(true)
                        ),
                    s => s.
                    MatchPhrasePrefix(p => p
                       .Field(fi => fi.Name)
                       .Query(searchTerm)
                       .Analyzer("synonym_analyzer")
                       .Boost(0.8)
                       .Lenient(true))
                       )))

And here's the mapping:

            .Mappings(m => m
            .Map<Item>(u => u
                .Properties(p => p
                    .Text(t => t.Name(n => n.Name)
                        .IndexOptions(IndexOptions.Positions)
                        .Analyzer("synonym_analyzer")
                    )
                    .Text(t => t.Name(n => n.Items.First().Cat))
                    .Text(t => t.Name(n => n.Items.First().Id))
                    .Text(t => t.Name(n => n.CustomAttributes["Expiration"]))                            
                )
            )
        )

Do you have the json version of those?

I don't. I currently exclusively use NEST.

Do you mean that you can't debug with .Net what is generated and sent over the network?

If you can't I can't help sorry. May be someone else can though.

I really wish Nest had more straightforward support for Query extraction, but here's what I managed to come up with:

{
   "bool":{
      "should":[
         {
            "match":{
               "Items.Id":{
                  "type":"phrase",
                  "query":"hydrogenated polybutene (370 mw)"
               }
            }
         },
         {
            "fuzzy":{
               "Items.Cat":{
                  "value":"hydrogenated polybutene (370 mw)"
               }
            }
         },
         {
            "match":{
               "name":{
                  "type":"phrase",
                  "query":"hydrogenated polybutene (370 mw)",
                  "analyzer":"synonym_analyzer",
                  "fuzziness":2
               }
            }
         },
         {
            "match":{
               "name":{
                  "boost":0.8,
                  "type":"phrase_prefix",
                  "query":"hydrogenated polybutene (370 mw)",
                  "analyzer":"synonym_analyzer"
               }
            }
         }
      ]
   }
}

Thanks. Have a look at https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html

Is the existence of the "type" field in the query the cause of the error?

Yes. This old option does not exist. See https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html

Which means Nest is completely incompatible with ElasticSearch 6.0; because as shown in my code, I'm using the appropriate functions.

I suppose that you upgraded your nest version, right?

@Martijn_Laarman can help hopefully.

Check out the compatibility matrix: https://github.com/elastic/elasticsearch-net#compatibility-matrix

The beta1 of NEST for Elasticsearch 6.x has just come out, so that's your best option at the moment. I assume you're still on a stable NEST version, which is only compatible with 5.x, right?

1 Like

FWIW, NEST 6.0.0-rc1 resolved this issue for me.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.