# Search with fields wildcard not working

**URL:** <https://discuss.elastic.co/t/search-with-fields-wildcard-not-working/133240>\
**Category:** Elasticsearch\
**Created:** [May 25, 2018, 3:11am UTC](https://discuss.elastic.co/t/search-with-fields-wildcard-not-working/133240 "2018-05-25T03:11:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yuhao\_zhang](https://avatars.discourse-cdn.com/v4/letter/y/fbc32d/32.png) [@yuhao\_zhang](https://discuss.elastic.co/u/yuhao_zhang)\
**Post date:** [May 25, 2018, 3:11am UTC](https://discuss.elastic.co/t/search-with-fields-wildcard-not-working/133240/1 "2018-05-25T03:11:21Z")

</div>

Hi Currently I am working on elasticsearch 6.2.4  
I am not able to perform the wildcard search within specific inner elements of the document like this ([https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html))

this is my document

```
PUT test/wf/2
{
      "uuid": "51ab247d-033a-4860-97b5-8a58e24a1e0c",
      "writingUuid": {
        "uuid": "943c2055-3cd3-4e6d-b0bb-2d54b1bfec25",
        "nativeUrl": "https://www.todayonline.com/singapore/tighter-security-checkpoints-orchard-road-over-year-end-holiday-period-ica-police",
        "title": "TODAY",
        "content": "Tighter security at checkpoints, Orchard Road over year-end holiday period: ICA, police SINGAPORE Expect tighter security checks if you are headed to town or out of the country during the upcoming year-end holiday break the police and immigration authorities said on Wednesday Dec 20. In separate press releases the Immigrations and Checkpoints Authority IHeaded to town over the long weekend? Take note that checks and security measures will be stepped up in anticipation of bigger crowds during the festive period.",
        "nativeTimeCreated": 1513716000000,
        "kfactsId": "23f48e11-715f-4773-a822-c154a821ac96",
        "platformUuid": {
          "uuid": "caa13e4f-edda-44b5-b124-278e3dbb5430",
          "parentUuid": null,
          "name": "facebook",
          "url": "https://www.facebook.com/",
          "isDeleted": false
        }
      },
      "timeCreated": 1513717846789
  }

```

I try to do a query on it as the way mentioned in the documentation:

```
GET /test/_search
{
  "query": {
    "query_string": {
      "query": "tighter security",
      "fields": ["writingUuid.*"]
    }
  }
}

```

it gives me error below

```
{
  "error": {
     "root_cause": [
       {
        "type": "query_shard_exception",
        "reason": "failed to create query: {\n \"query_string\" : {\n \"query\" : \"tighter security\",\n    
\"fields\" : [\n \"writingUuid.*^1.0\"\n],\n \"type\" : \"best_fields\",\n \"default_operator\" : 
\"or\",\n \"max_determinized_states\" : 10000,\n \"enable_position_increments\" : true,\n    
\"fuzziness\" : \"AUTO\",\n \"fuzzy_prefix_length\" : 0,\n \"fuzzy_max_expansions\" : 50,\n    
\"phrase_slop\" : 0,\n \"escape\" : false,\n \"auto_generate_synonyms_phrase_query\" : true,\n    
\"fuzzy_transpositions\" : true,\n \"boost\" : 1.0\n }\n}",
        "index_uuid": "8E81lxejRdKL9HZyc9ASRg",
        "index": "test"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "test",
        "node": "uIDC0NOfSiK3ON0UwY3JCQ",
        "reason": {
          "type": "query_shard_exception",
          "reason": "failed to create query: {\n \"query_string\" : {\n \"query\" : \"tighter security\",\n    
\"fields\" : [\n \"writingUuid.*^1.0\"\n],\n \"type\" : \"best_fields\",\n \"default_operator\" : 
\"or\",\n \"max_determinized_states\" : 10000,\n \"enable_position_increments\" : true,\n    
\"fuzziness\" : \"AUTO\",\n \"fuzzy_prefix_length\" : 0,\n \"fuzzy_max_expansions\" : 50,\n    
\"phrase_slop\" : 0,\n \"escape\" : false,\n \"auto_generate_synonyms_phrase_query\" : true,\n    
\"fuzzy_transpositions\" : true,\n \"boost\" : 1.0\n }\n}",
          "index_uuid": "8E81lxejRdKL9HZyc9ASRg",
          "index": "test",
          "caused_by": {
            "type": "number_format_exception",
            "reason": "For input string: \"tighter security\""
          }
        }
      }
    ]
 },
  "status": 400
}

```

if I try to query like this:

```
GET /test/_search
{
  "query": {
    "query_string": {
      "query": "tighter security",
      "fields": ["writingUuid"]
    }
  }
}

```

this will not return an error but it does not return any hits:

```
{
  "took": 2,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 0,
    "max_score": null,
    "hits": []
  }
}

```

Unless I specified the field name it will return the result:

```
GET /test/_search
{
  "query": {
    "query_string": {
      "query": "tighter security",
      "fields": ["writingUuid.content"]
    }
  }
}

```

Anyone can help me with this issue?

---

<div class="post-metadata">

**Author:** ![yuhao\_zhang](https://avatars.discourse-cdn.com/v4/letter/y/fbc32d/32.png) [@yuhao\_zhang](https://discuss.elastic.co/u/yuhao_zhang)\
**Post date:** [May 28, 2018, 6:47am UTC](https://discuss.elastic.co/t/search-with-fields-wildcard-not-working/133240/2 "2018-05-28T06:47:07Z")

</div>

Anyone can help me with this issue?

---

<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:** [May 29, 2018, 6:59am UTC](https://discuss.elastic.co/t/search-with-fields-wildcard-not-working/133240/3 "2018-05-29T06:59:15Z")

</div>

The problem is that you are searching for a text `tighter security` in all fields, including `nativeTimeCreated` which is a number.

Use the `lenient` option:

```auto
GET /test/_search
{
  "query": {
    "query_string": {
      "query": "tighter security",
      "fields": ["writingUuid.*"],
      "lenient": true
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![yuhao\_zhang](https://avatars.discourse-cdn.com/v4/letter/y/fbc32d/32.png) [@yuhao\_zhang](https://discuss.elastic.co/u/yuhao_zhang)\
**Post date:** [May 29, 2018, 10:45am UTC](https://discuss.elastic.co/t/search-with-fields-wildcard-not-working/133240/4 "2018-05-29T10:45:34Z")

</div>

It works, thanks a lot!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 26, 2018, 10:45am UTC](https://discuss.elastic.co/t/search-with-fields-wildcard-not-working/133240/5 "2018-06-26T10:45:40Z")

</div>

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