# Wildcard query rewrite parameter not working with new wildcard field type?

**URL:** <https://discuss.elastic.co/t/wildcard-query-rewrite-parameter-not-working-with-new-wildcard-field-type/265453>\
**Category:** Elasticsearch\
**Created:** [February 25, 2021, 8:42am UTC](https://discuss.elastic.co/t/wildcard-query-rewrite-parameter-not-working-with-new-wildcard-field-type/265453 "2021-02-25T08:42:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cads](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@cads](https://discuss.elastic.co/u/cads)\
**Post date:** [February 25, 2021, 8:42am UTC](https://discuss.elastic.co/t/wildcard-query-rewrite-parameter-not-working-with-new-wildcard-field-type/265453/1 "2021-02-25T08:42:42Z")

</div>

The Wildcard Query offers a rewrite parameter to influence how Lucene calculates the relevance scores. On keyword fields this works as expected but it does not seem to work with the new wildcard field type which belongs to the keyword family. Is this an expected behavior or a bug?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [February 25, 2021, 12:02pm UTC](https://discuss.elastic.co/t/wildcard-query-rewrite-parameter-not-working-with-new-wildcard-field-type/265453/2 "2021-02-25T12:02:32Z")

</div>

I think it's safe to assume the `rewrite` parameter is unsupported. Unlike keyword fields, the wildcard field doesn't have a single indexed token for each term so it has no pre-built count for the document frequency of whole values. Instead it uses an ngram index which obviously has different frequencies for the multiple terms a search string can be broken down into.

---

<div class="post-metadata">

**Author:** ![cads](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@cads](https://discuss.elastic.co/u/cads)\
**Post date:** [February 25, 2021, 1:11pm UTC](https://discuss.elastic.co/t/wildcard-query-rewrite-parameter-not-working-with-new-wildcard-field-type/265453/3 "2021-02-25T13:11:14Z")

</div>

Thank you for your reply, that clears things up. Perhaps this should be mentioned in the documentation.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [February 25, 2021, 1:48pm UTC](https://discuss.elastic.co/t/wildcard-query-rewrite-parameter-not-working-with-new-wildcard-field-type/265453/4 "2021-02-25T13:48:53Z")

</div>

Will do. Thanks for flagging. I opened [Wildcard field should use constant\_score and reject wildcard query `rewrite` param · Issue #69604 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/issues/69604) to track

---

<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:** [March 25, 2021, 1:49pm UTC](https://discuss.elastic.co/t/wildcard-query-rewrite-parameter-not-working-with-new-wildcard-field-type/265453/5 "2021-03-25T13:49:22Z")

</div>

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