# Text-search using URI param query failing after upgrade to 6.2.2 from 5.4.1

**URL:** <https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368>\
**Category:** Elasticsearch\
**Created:** [March 10, 2018, 4:58am UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368 "2018-03-10T04:58:42Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![vramakrishnan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vramakrishnan/32/31750_2.png) [@vramakrishnan](https://discuss.elastic.co/u/vramakrishnan)\
**Post date:** [March 10, 2018, 4:58am UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/1 "2018-03-10T04:58:42Z")

</div>

I have a mapping for a field Tenant defined as follows.  
"Tenant": {  
"type": "keyword"  
},

And I use to do elastic query using URI param  
localhost:9200/\_search?q=foo (simple text search on "foo")  
and used to get matching docs with Tenant set "foo" with elastic 5.4.1

After upgrading to elastic 6.2.2, the same query with the same index mapping is not returning any matching result.  
{"took":1,"timed\_out":false,"\_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":0,"max\_score":nul

Has something changed in 6.x.x that requires different index mapping or query format for URI param for text search?

Do I need to have both text and keyword mapping defined - for fields that needs text search as well as aggregation support with 6.x.x ?

---

<div class="post-metadata">

**Author:** ![Melvyn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/melvyn/32/35269_2.png) [@Melvyn](https://discuss.elastic.co/u/Melvyn)\
**Post date:** [March 10, 2018, 2:42pm UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/2 "2018-03-10T14:42:00Z")

</div>

Nothing that would affect an URI search has changed as far as I know. I reproduced your situation and was successful. Do you have document in your cluster that match "foo"?

---

<div class="post-metadata">

**Author:** ![vramakrishnan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vramakrishnan/32/31750_2.png) [@vramakrishnan](https://discuss.elastic.co/u/vramakrishnan)\
**Post date:** [March 10, 2018, 6:05pm UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/3 "2018-03-10T18:05:52Z")

</div>

I see the text search is failing for nested objects only with the same schema that worked with 5.4.1

```auto
  "mappings" : {
      "configs" : {
        "properties" : {
          "APIVersion" : {
            "type" : "text"
          },
          "Kind" : "TypeFoo",
          "meta" : { <<<<<
            "type" : "nested",
            "properties" : {
              "CreationTime" : {
                "type" : "date"
              },
              "ModTime" : {
                "type" : "date"
              },
              "Name" : {
                "type" : "text"
              },
              "Tenant" : {
                "type" : "keyword" <<<<
              },

```

Here is the object in Elastic.

```auto
        "_source" : {
          "APIVersion" : "v1",
          "Kind" : "TypeFoo",
          "meta" : {
            "Name" : "sg03",
            "Tenant" : "audi", <----
...
           }

```

The following text query returns no match with 6.2.2 but works with 5.4.1

curl localhost:9200/myindex.\*/\_search?q=audi  
{"took":2,"timed\_out":false,"\_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":0,"max\_score":null,"hits":[]}}

Also also these term query on nested object fails with no match.

```
    curl localhost:9200/myindex.*/_search?q=meta.Tenant:audi

    curl localhost:9200/myindex.*/_search?q=Tenant:audi

```

This query on outer object works. (text or term)

```
    curl localhost:9200/myindex.*/_search?q=TypeFoo

    curl localhost:9200/myindex.*/_search?q=Kind:TypeFoo
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 10, 2018, 6:22pm UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/4 "2018-03-10T18:22:45Z")

</div>

That's because you can't do nested queries on `nested` objects without using the QueryDSL I think.

---

<div class="post-metadata">

**Author:** ![vramakrishnan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vramakrishnan/32/31750_2.png) [@vramakrishnan](https://discuss.elastic.co/u/vramakrishnan)\
**Post date:** [March 10, 2018, 6:29pm UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/5 "2018-03-10T18:29:47Z")

</div>

Thanks for the response.

Text search using URI param is working with 5.4.1 (text search at any object level) and did it change with 5.5 or in 6.x ?

```
         curl localhost:9200/myindex.*/_search?q=audi. <<<<<<

```

Is there a workaround to get text search working with 6.2.2 for any object level using URI query string parameter ?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 10, 2018, 6:40pm UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/6 "2018-03-10T18:40:51Z")

</div>

Are you sure the mapping in 5.x had this `nested` type in it?

Can you run:

```auto
GET your_index/_mapping

```

On the 5.6 cluster?

---

<div class="post-metadata">

**Author:** ![vramakrishnan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vramakrishnan/32/31750_2.png) [@vramakrishnan](https://discuss.elastic.co/u/vramakrishnan)\
**Post date:** [March 10, 2018, 6:49pm UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/7 "2018-03-10T18:49:28Z")

</div>

Yes. The mapping is same on both versions and Tenant is nested attribute.

Here is the output with 5.4.1.

It is very easy to repro.

```auto
 $ curl localhost:9200
{
  "name" : "ZgsXWKs",
  "cluster_uuid" : "z8Ev1YWOTESRztEivh73HQ",
  "version" : {
    "number" : "5.4.1", <<<<<<<<<<<<<<<<
    "build_hash" : "2cfe0df",
    "build_date" : "2017-05-29T16:05:51.443Z",
    "build_snapshot" : false,
    "lucene_version" : "6.5.1"
  },
  "tagline" : "You Know, for Search"
}

$ curl localhost:9200/myindex.*/_mapping?pretty
{
    "mappings" : {
      "configs" : {
        "properties" : {
          "APIVersion" : {
            "type" : "text"
          },
          "Kind" : {
            "type" : "keyword"
          },
          "meta" : {
            "type" : "nested", <<<<<<<<<<<<<<
            "properties" : {
              "CreationTime" : {
                "type" : "date"
              },
              "Name" : {
                "type" : "text"
              },
              "Namespace" : {
                "type" : "keyword"
              },
              "Tenant" : {
                "type" : "keyword". <<<<<<<<<<<<<
              },
            }
          },

```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 10, 2018, 6:52pm UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/8 "2018-03-10T18:52:44Z")

</div>

Can you share a full repro script that I can reuse?

---

<div class="post-metadata">

**Author:** ![vramakrishnan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vramakrishnan/32/31750_2.png) [@vramakrishnan](https://discuss.elastic.co/u/vramakrishnan)\
**Post date:** [March 10, 2018, 7:01pm UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/9 "2018-03-10T19:01:32Z")

</div>

Sorry we dont have a standalone script. But direct-messaged you the index mapping . Appreciate your help in this regard.

---

<div class="post-metadata">

**Author:** ![vramakrishnan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vramakrishnan/32/31750_2.png) [@vramakrishnan](https://discuss.elastic.co/u/vramakrishnan)\
**Post date:** [March 10, 2018, 8:39pm UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/10 "2018-03-10T20:39:48Z")

</div>

Another data point - URI text search on nested objects for the mapping I had works in 5.5.0 as well.

It starts failing from 6.0.0 onwards.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 10, 2018, 8:45pm UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/11 "2018-03-10T20:45:24Z")

</div>

So if I have time to create a reproduction script, I'll look at it.  
Unless someone else has spare time.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 12, 2018, 3:20pm UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/12 "2018-03-12T15:20:07Z")

</div>

Why not sharing that here?

---

<div class="post-metadata">

**Author:** ![vramakrishnan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vramakrishnan/32/31750_2.png) [@vramakrishnan](https://discuss.elastic.co/u/vramakrishnan)\
**Post date:** [March 12, 2018, 4:37pm UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/13 "2018-03-12T16:37:03Z")

</div>

It is in GO backend code with properietary code inter-twined and would take more effort share it in public.

Maybe will provide CURL and bash scripts some time this week.

---

<div class="post-metadata">

**Author:** ![vramakrishnan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vramakrishnan/32/31750_2.png) [@vramakrishnan](https://discuss.elastic.co/u/vramakrishnan)\
**Post date:** [March 13, 2018, 6:28pm UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/14 "2018-03-13T18:28:22Z")

</div>

Here are steps to repro on 6.2.2

```auto
# verify elastic endpoint is up with version 6.2.2
curl localhost:9200

# create myindex with mapping
curl -H 'Content-Type: application/json' -XPUT -d '{ "mappings": { "configs": { "properties": { "Kind": { "type": "keyword" }, "meta": { "type": "nested", "properties": { "Name": { "type": "text" }, "Tenant": { "type": "keyword" } } } } } } }' http://localhost:9200/myindex

# verify mapping
curl localhost:9200/myindex/_mapping?pretty

# add doc/object
curl -H 'Content-Type: application/json' -d '{ "Kind": "foo", "meta": { "Name": "sg03", "Tenant": "audi" } }' http://localhost:9200/myindex/configs

# verify object
curl localhost:9200/myindex/_search?pretty

# text search on outer field (Kind's) value
curl localhost:9200/myindex/_search?q=foo

# text search on nested field (Tenant's) value
curl localhost:9200/myindex/_search?q=audi

```

Here is my repro with output shown ...

```auto
MacBook-Pro[search] $ curl localhost:9200
{
  "name" : "iP_9TW_",
  "cluster_name" : "test-elasticcluster",
  "cluster_uuid" : "HtH7CfY0Sd6QxoAtBaxVUA",
  "version" : {
    "number" : "6.2.2",
    "build_hash" : "10b1edd",
    "build_date" : "2018-02-16T19:01:30.685723Z",
    "build_snapshot" : false,
    "lucene_version" : "7.2.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

MacBook-Pro[search] $ curl -H 'Content-Type: application/json' -XPUT -d '{ "mappings": { "configs": { "properties": { "Kind": { "type": "keyword" }, "meta": { "type": "nested", "properties": { "Name": { "type": "text" }, "Tenant": { "type": "keyword" } } } } } } }' http://localhost:9200/myindex
{"acknowledged":true,"shards_acknowledged":true,"index":"myindex"}

MacBook-Pro[search] $ curl localhost:9200/myindex/_mapping?pretty
{
  "myindex" : {
    "mappings" : {
      "configs" : {
        "properties" : {
          "Kind" : {
            "type" : "keyword"
          },
          "meta" : {
            "type" : "nested",
            "properties" : {
              "Name" : {
                "type" : "text"
              },
              "Tenant" : {
                "type" : "keyword"
              }
            }
          }
        }
      }
    }
  }
}

MacBook-Pro[search] $ curl -H 'Content-Type: application/json' -d '{ "Kind": "foo", "meta": { "Name": "sg03", "Tenant": "audi" } }' http://localhost:9200/myindex/configs
{"_index":"myindex","_type":"configs","_id":"KpGcIGIBHBDa29EzJsNU","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":0,"_primary_term":1}

MacBook-Pro[search] $ curl localhost:9200/myindex/_search?pretty
{
  "took" : 85,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "myindex",
        "_type" : "configs",
        "_id" : "KpGcIGIBHBDa29EzJsNU",
        "_score" : 1.0,
        "_source" : {
          "Kind" : "foo",
          "meta" : {
            "Name" : "sg03",
            "Tenant" : "audi"
          }
        }
      }
    ]
  }
}

## Text search on outer field - HIT/WORKS
MacBook-Pro[search] $ curl localhost:9200/myindex/_search?q=foo
{"took":18,"timed_out":false,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0},"hits":{"total":1,"max_score":0.2876821,"hits":[{"_index":"myindex","_type":"configs","_id":"KpGcIGIBHBDa29EzJsNU","_score":0.2876821,"_source":{ "Kind": "foo", "meta": { "Name": "sg03", "Tenant": "audi" } }}]}}

## Text search on inner field - MISS
MacBook-Pro[search] $ curl localhost:9200/myindex/_search?q=audi
{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}

```

---

<div class="post-metadata">

**Author:** ![vramakrishnan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vramakrishnan/32/31750_2.png) [@vramakrishnan](https://discuss.elastic.co/u/vramakrishnan)\
**Post date:** [March 14, 2018, 3:37pm UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/15 "2018-03-14T15:37:08Z")

</div>

Elastic team - Please let me know if you need more info with above mentioned repro steps.

It is blocking our upgrade to 6.2.2 and really appreciate your time and help on the QueryString style query - text search on nested objects. We see this issue in all request forms - CURL with URI param, GET with body or even in code using elastic go client (querystring query).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 14, 2018, 4:12pm UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/16 "2018-03-14T16:12:21Z")

</div>

I think that the difference is that we don't generate anymore this catch all field `_all` anymore.

I believe that if you really need to do that, you have to use the `copy_to` feature and generate a `_all` like field which you can use in the query string query as the "default field".

---

<div class="post-metadata">

**Author:** ![vramakrishnan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vramakrishnan/32/31750_2.png) [@vramakrishnan](https://discuss.elastic.co/u/vramakrishnan)\
**Post date:** [March 14, 2018, 4:30pm UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/17 "2018-03-14T16:30:26Z")

</div>

I see.

May I know how do we make it work for dynamic mappings?

We have defined static mapping for meta/header fields in objects and rest of the fields is dynamically mapped. My requirement is to provide a simple text search service on all object fields, including nested - either coming via static mapping pre-defined or dynamic mapping.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 14, 2018, 5:02pm UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/18 "2018-03-14T17:02:18Z")

</div>

You can use this: [https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html)

---

<div class="post-metadata">

**Author:** ![vramakrishnan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vramakrishnan/32/31750_2.png) [@vramakrishnan](https://discuss.elastic.co/u/vramakrishnan)\
**Post date:** [March 14, 2018, 9:16pm UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/19 "2018-03-14T21:16:05Z")

</div>

Thanks David for the help.

Have a final question for this thread.

I tried the copy\_to and it works for first level nested object, but doesnt work for second and further level nested objects. May I know how to make it work for the meta.Labels.key field to use copy\_to in this example

```auto
{
	"mappings": {
		"configs": {
			"properties": {
				"catch_all": {
					"type": "text"
				},
				"Kind": {
					"type": "keyword"
				},
				"meta": {
					"type": "nested",
					"properties": {
						"Name": {
							"type": "text",
							"copy_to": "catch_all"
						},
						"Tenant": {
							"type": "keyword",
							"copy_to": "catch_all"
						}
					},
					"Labels": {
						"type": "nested",
						"properties": {
							"key": {
								"type": "text",
								"copy_to": "catch_all" <<<< this is not taking effect
							}
						}
					}
				}
			}
		}
	}
}

```

I also tried creating a inner meta\_catch\_all and propagate it to outer catch\_call and it didnt help.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 14, 2018, 9:51pm UTC](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368/20 "2018-03-14T21:51:26Z")

</div>

Might be a bug. @jpountz WDYT ?

[Next page](https://discuss.elastic.co/t/text-search-using-uri-param-query-failing-after-upgrade-to-6-2-2-from-5-4-1/123368.md?page=2)
