# How to configure fields for wildcard search?

**URL:** <https://discuss.elastic.co/t/how-to-configure-fields-for-wildcard-search/86851>\
**Category:** Elasticsearch\
**Created:** [May 23, 2017, 6:34pm UTC](https://discuss.elastic.co/t/how-to-configure-fields-for-wildcard-search/86851 "2017-05-23T18:34:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave-Nuxeo](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@Dave-Nuxeo](https://discuss.elastic.co/u/Dave-Nuxeo)\
**Post date:** [May 23, 2017, 6:34pm UTC](https://discuss.elastic.co/t/how-to-configure-fields-for-wildcard-search/86851/1 "2017-05-23T18:34:02Z")

</div>

Here's a config file. The fields that are listed as **properties** are the fields that I would like to be able to do a wildcard search on. So for instance, if I type \*foo\* into our search box, I would get all results that have properties matching the substring "foo".

```
"version" : {
    "number" : "2.3.5",
    "build_hash" : "90f439ff60a3c0f497f91663701e64ccd01edbb4",
    "build_timestamp" : "2016-07-27T10:36:52Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.0"
  },

```

Here is the config file excerpt:

```
  <extension target="org.nuxeo.elasticsearch.ElasticSearchComponent"
    point="elasticSearchIndex">
    <elasticSearchIndex name="${elasticsearch.indexName}" type="doc" repository="default">
      <fetchFromSource>
        <include>ecm:*</include>
        <include>dc:*</include>
        <exclude>ecm:binarytext</exclude>
      </fetchFromSource>

      <settings>
{
   "analysis" : {
      "filter" : {
         "truncate_filter" : {
            "length" : 256,
            "type" : "truncate"
         },
         "word_delimiter_filter" : {
           "type" : "word_delimiter",
           "preserve_original" : true
         },
         "asciifolding_filter" : {
            "type" : "asciifolding",
            "preserve_original" : true
         },
         "en_stem_filter" : {
            "name" : "minimal_english",
            "type" : "stemmer"
         },
         "en_stop_filter" : {
            "stopwords" : [
               "_english_"
            ],
            "type" : "stop"
         },
         "fr_elision_filter" : {
            "articles" : [
               "c",
               "l",
               "m",
               "t",
               "qu",
               "n",
               "s",
               "j"
            ],
            "type" : "elision"
         },
         "fr_stem_filter" : {
            "name" : "minimal_french",
            "type" : "stemmer"
         },
         "fr_stop_filter" : {
            "stopwords" : [
               "_french_"
            ],
            "type" : "stop"
         },
         "mynGram": {
          "type": "nGram",
          "min_gram": 4,
          "max_gram": 4
        }
      },
      "tokenizer" : {
         "path_tokenizer" : {
            "delimiter" : "/",
            "type" : "path_hierarchy"
         }
      },
      "analyzer" : {
         "en_analyzer" : {
            "alias" : "fulltext",
            "char_filter": ["html_strip"],
            "filter" : [
               "lowercase",
               "mynGram"
            ],
            "type" : "custom",
            "tokenizer" : "standard"
         },
         "fr_analyzer" : {
            "char_filter": ["html_strip"],
            "filter" : [
               "word_delimiter_filter",
               "lowercase",
               "fr_stop_filter",
               "fr_stem_filter",
               "asciifolding_filter",
               "fr_elision_filter"
            ],
            "type" : "custom",
            "tokenizer" : "standard"
         },
         "path_analyzer" : {
            "type" : "custom",
            "tokenizer" : "path_tokenizer"
         },
         "lowercase_analyzer" : {
            "type" : "custom",
            "filter" : ["truncate_filter", "lowercase", "asciifolding"],
            "tokenizer" : "keyword"
         },
         "default" : {
            "type" : "custom",
            "filter" : ["truncate_filter"],
            "tokenizer" : "keyword"
         }
      }
   }
}
      </settings>
      <mapping>
{
   "_all" : {
      "analyzer" : "fulltext"
   },
   "dynamic_templates": [ {
      "no_thumbnail_template": {
         "path_match": "thumb:thumbnail.*",
         "mapping": {
             "index": "no",
             "include_in_all": false
            }
         }
      }, {
      "no_picture_template": {
         "path_match": "picture:views.*",
         "mapping": {
            "index": "no",
            "include_in_all": false
          }
       }
   } ],
   "properties" : {
      "dc:title" : {
         "type" : "multi_field",
         "fields" : {
           "dc:title" : {
             "type" : "string"
           },
           "fulltext" : {
             "boost": 2,
             "type": "string",
             "analyzer" : "fulltext"
          }
        }
      },
      "dc:description" : {
         "type" : "multi_field",
         "fields" : {
           "dc:description" : {
             "index" : "no",
             "include_in_all" : true,
             "type" : "string"
           },
           "fulltext" : {
             "boost": 1.5,
             "type": "string",
             "analyzer" : "fulltext"
          }
        }
      },
      "note:note" : {
         "type" : "multi_field",
         "fields" : {
           "note:note" : {
             "index" : "no",
             "include_in_all" : true,
             "type" : "string"
           },
           "fulltext" : {
             "type": "string",
             "analyzer" : "fulltext"
          }
        }
      },
      "ecm:binarytext" : {
         "type" : "string",
         "index" : "no",
         "include_in_all" : true
      },
      "ecm:path" : {
         "type" : "multi_field",
         "fields" : {
            "children" : {
               "analyzer" : "path_analyzer",
               "search_analyzer" : "keyword",
               "type" : "string"
            },
            "ecm:path" : {
               "index" : "not_analyzed",
               "type" : "string"
            }
         }
      },
      "ecm:pos": {
         "type": "integer"
      },
      "dc:created": {
         "format": "dateOptionalTime",
         "type": "date"
      },
      "dc:expired": {
         "format": "dateOptionalTime",
         "type": "date"
      },
      "dc:modified": {
         "format": "dateOptionalTime",
         "type": "date"
      },
      "common:icon": {
         "type": "string",
         "index" : "no",
         "include_in_all" : false
      }
	}
}
      </mapping>

    </elasticSearchIndex>
  </extension>

</component>
</#escape>
```

---

<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 23, 2017, 9:23pm UTC](https://discuss.elastic.co/t/how-to-configure-fields-for-wildcard-search/86851/2 "2017-05-23T21:23:39Z")

</div>

I would probably change the mapping to use as well a ngram based analyzer.

---

<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 20, 2017, 9:23pm UTC](https://discuss.elastic.co/t/how-to-configure-fields-for-wildcard-search/86851/3 "2017-06-20T21:23:50Z")

</div>

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