# Subdomain term Query

**URL:** <https://discuss.elastic.co/t/subdomain-term-query/234329>\
**Category:** Elasticsearch\
**Created:** [May 26, 2020, 12:21pm UTC](https://discuss.elastic.co/t/subdomain-term-query/234329 "2020-05-26T12:21:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankitsynX](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ankitsynx/32/64535_2.png) [@ankitsynX](https://discuss.elastic.co/u/ankitsynX)\
**Post date:** [May 26, 2020, 12:21pm UTC](https://discuss.elastic.co/t/subdomain-term-query/234329/1 "2020-05-26T12:21:31Z")

</div>

Hi All,

I am building a lookup query for matching domain names using terms query.  
My lookup index is indexed as keyword.

My search index has the domain field indexed as text and keyword both.

There are possible four scenarios:

1. All keyword approach -Lookup index field indexed as keyword and search index field indexed as keyword as well.  
Results: Only exact matches are returned after lookup. This does not allow subdomain lookup unless it's indexed in the lookup index.

2. Lookup field is indexed as keyword and search index field is indexed as text.  
Results: Exact match is working sub domains are not matched

3. Lookup field is indexed as text as well as search field is text  
Results: Exact match is working sub domains are not matched

4. Lookup term is indexed as text and search field as keyword  
Results: Exact match is working sub domains are not matched

These results are after testing on ES 7.5.2.  
Any guidance would be appreciated. The idea is to identify any subdomains appearing in the search index against a lookup in the lookup index using terms query.

~ Ankit

---

<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 23, 2020, 12:21pm UTC](https://discuss.elastic.co/t/subdomain-term-query/234329/2 "2020-06-23T12:21:37Z")

</div>

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