# Term and string

**URL:** https://discuss.elastic.co/t/term-and-string/23378
**Category:** Elasticsearch
**Created:** [April 23, 2015, 2:42pm UTC](https://discuss.elastic.co/t/term-and-string/23378 "2015-04-23T14:42:13Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Jason\_Wee](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Jason\_Wee](https://discuss.elastic.co/u/Jason_Wee)
#### Post date: [April 23, 2015, 2:42pm UTC](https://discuss.elastic.co/t/term-and-string/23378/1 "2015-04-23T14:42:13Z")

</div>

Can anybody explain what is the different between term and string in  
elasticsearch context?

When we index using default mapping  
([http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html](http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html)),  
the default type is string.

But when we query, we use the word term  
([http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html](http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html))  
instead of string?

I google lucene documentation, the term is define as

A query is broken up into terms and operators. There are two types of  
terms: Single Terms and Phrases. A Single Term is a single word such as  
"test" or "hello". A Phrase is a group of words surrounded by double quotes  
such as "hello dolly".

but it has no mentioned on string.

[https://lucene.apache.org/core/4\_10\_3/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package\_description](https://lucene.apache.org/core/4_10_3/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package_description)

Thank you.

Jason

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/df898132-f7f8-4476-8a81-21e3891dfb1a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/df898132-f7f8-4476-8a81-21e3891dfb1a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![softwaredoug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/softwaredoug/32/22681_2.png) [@softwaredoug](https://discuss.elastic.co/u/softwaredoug)
#### Post date: [April 23, 2015, 2:56pm UTC](https://discuss.elastic.co/t/term-and-string/23378/2 "2015-04-23T14:56:00Z")

</div>

A _term_ in a purely technical sense is an entry in the inverted index.  
Technically it is a very low-level entity.

For example, if you tokenized and analyzed doc1: "Dougie Turnbull" using  
the English analyzer (which stems words to root forms, lowercases, etc),  
you'd get an inverted index that looks somethinglike:

doug  
document: 1  
position 0  
freq 1  
turnbul  
document: 1  
position 1  
freq 1

A "term query" therefore directly accesses terms. Its a bit of a low-level  
concern. You'd have to query "doug" directly even though the original text  
said "dougie".

However, loosely people use the word "search term" to mean words people  
enter into a search bar.

"string" is a concept that just reflects the text being analyzed. IE  
"Dougie Turnbull". This type is at the Elasticsearch level, and is a peer  
for integer, floats, doubles etc. This type dicates how Elasticsearch  
understands the value passed from the client and converts it to the  
inverted index structure above. A string type will be analyzed, picked  
apart into terms, etc based on the associated analyzer. Other types like  
numeric types have other low-level magic that helps convert them to the  
inverted index data structure.

Hope that helps,  
-Doug

On Thu, Apr 23, 2015 at 10:42 AM, Jason Wee [peichieh@gmail.com](mailto:peichieh@gmail.com) wrote:

> Can anybody explain what is the different between term and string in  
> elasticsearch context?
> 
> When we index using default mapping (  
> [Update mapping API | Elasticsearch Guide [8.11] | Elastic](http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html)),  
> the default type is string.
> 
> But when we query, we use the word term (  
> [Term query | Elasticsearch Guide [8.11] | Elastic](http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html))  
> instead of string?
> 
> I google lucene documentation, the term is define as
> 
> A query is broken up into terms and operators. There are two types of  
> terms: Single Terms and Phrases. A Single Term is a single word such as  
> "test" or "hello". A Phrase is a group of words surrounded by double  
> quotes such as "hello dolly".
> 
> but it has no mentioned on string.
> 
> [org.apache.lucene.queryparser.classic (Lucene 4.10.3 API)](https://lucene.apache.org/core/4_10_3/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package_description)
> 
> Thank you.
> 
> Jason
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/df898132-f7f8-4476-8a81-21e3891dfb1a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/df898132-f7f8-4476-8a81-21e3891dfb1a%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/df898132-f7f8-4476-8a81-21e3891dfb1a%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/df898132-f7f8-4476-8a81-21e3891dfb1a%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
\*Doug Turnbull \*\*| \*Search Relevance Consultant | OpenSource Connections,  
LLC | 240.476.9983 | [http://www.opensourceconnections.com](http://www.opensourceconnections.com)  
Author: Taming Search [http://manning.com/turnbull](http://manning.com/turnbull) from Manning  
Publications  
This e-mail and all contents, including attachments, is considered to be  
Company Confidential unless explicitly stated otherwise, regardless  
of whether attachments are marked as such.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALG6HL8RtomqZ3tWxB%2BEN2q\_JHZmppGwzVw0HfPWJjTmzVNXCw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALG6HL8RtomqZ3tWxB%2BEN2q_JHZmppGwzVw0HfPWJjTmzVNXCw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Jason\_Wee](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Jason\_Wee](https://discuss.elastic.co/u/Jason_Wee)
#### Post date: [April 24, 2015, 2:09am UTC](https://discuss.elastic.co/t/term-and-string/23378/3 "2015-04-24T02:09:53Z")

</div>

Yeap, that help, thanks Doug! 🙂

On Thu, Apr 23, 2015 at 10:56 PM, Doug Turnbull  
[dturnbull@opensourceconnections.com](mailto:dturnbull@opensourceconnections.com) wrote:

> A term in a purely technical sense is an entry in the inverted index.  
> Technically it is a very low-level entity.
> 
> For example, if you tokenized and analyzed doc1: "Dougie Turnbull" using the  
> English analyzer (which stems words to root forms, lowercases, etc), you'd  
> get an inverted index that looks somethinglike:
> 
> doug  
> document: 1  
> position 0  
> freq 1  
> turnbul  
> document: 1  
> position 1  
> freq 1
> 
> A "term query" therefore directly accesses terms. Its a bit of a low-level  
> concern. You'd have to query "doug" directly even though the original text  
> said "dougie".
> 
> However, loosely people use the word "search term" to mean words people  
> enter into a search bar.
> 
> "string" is a concept that just reflects the text being analyzed. IE "Dougie  
> Turnbull". This type is at the Elasticsearch level, and is a peer for  
> integer, floats, doubles etc. This type dicates how Elasticsearch  
> understands the value passed from the client and converts it to the inverted  
> index structure above. A string type will be analyzed, picked apart into  
> terms, etc based on the associated analyzer. Other types like numeric types  
> have other low-level magic that helps convert them to the inverted index  
> data structure.
> 
> Hope that helps,  
> -Doug
> 
> On Thu, Apr 23, 2015 at 10:42 AM, Jason Wee [peichieh@gmail.com](mailto:peichieh@gmail.com) wrote:
> 
> > Can anybody explain what is the different between term and string in  
> > elasticsearch context?
> > 
> > When we index using default mapping  
> > ([Update mapping API | Elasticsearch Guide [8.11] | Elastic](http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html)),  
> > the default type is string.
> > 
> > But when we query, we use the word term  
> > ([Term query | Elasticsearch Guide [8.11] | Elastic](http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html))  
> > instead of string?
> > 
> > I google lucene documentation, the term is define as
> > 
> > A query is broken up into terms and operators. There are two types of  
> > terms: Single Terms and Phrases. A Single Term is a single word such as  
> > "test" or "hello". A Phrase is a group of words surrounded by double quotes  
> > such as "hello dolly".
> > 
> > but it has no mentioned on string.
> > 
> > [org.apache.lucene.queryparser.classic (Lucene 4.10.3 API)](https://lucene.apache.org/core/4_10_3/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package_description)
> > 
> > Thank you.
> > 
> > Jason
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/df898132-f7f8-4476-8a81-21e3891dfb1a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/df898132-f7f8-4476-8a81-21e3891dfb1a%40googlegroups.com).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> Doug Turnbull | Search Relevance Consultant | OpenSource Connections, LLC |  
> 240.476.9983 | [http://www.opensourceconnections.com](http://www.opensourceconnections.com)  
> Author: Taming Search from Manning Publications  
> This e-mail and all contents, including attachments, is considered to be  
> Company Confidential unless explicitly stated otherwise, regardless of  
> whether attachments are marked as such.
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CALG6HL8RtomqZ3tWxB%2BEN2q\_JHZmppGwzVw0HfPWJjTmzVNXCw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALG6HL8RtomqZ3tWxB%2BEN2q_JHZmppGwzVw0HfPWJjTmzVNXCw%40mail.gmail.com).
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAHO4itziR1cpQn2jkB8SQmNDqYJUpxqqaNHDmPQu1d4u63dpiA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAHO4itziR1cpQn2jkB8SQmNDqYJUpxqqaNHDmPQu1d4u63dpiA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Jason\_Wee](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Jason\_Wee](https://discuss.elastic.co/u/Jason_Wee)
#### Post date: [May 3, 2015, 7:44am UTC](https://discuss.elastic.co/t/term-and-string/23378/4 "2015-05-03T07:44:48Z")

</div>

There are some terminology explain at this link.

> **[Glossary of terms | Reference \[0.90\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/0.90/glossary.html)**

On Fri, Apr 24, 2015 at 10:09 AM, Jason Wee [peichieh@gmail.com](mailto:peichieh@gmail.com) wrote:

> Yeap, that help, thanks Doug! 🙂
> 
> On Thu, Apr 23, 2015 at 10:56 PM, Doug Turnbull  
> [dturnbull@opensourceconnections.com](mailto:dturnbull@opensourceconnections.com) wrote:
> 
> > A term in a purely technical sense is an entry in the inverted index.  
> > Technically it is a very low-level entity.
> > 
> > For example, if you tokenized and analyzed doc1: "Dougie Turnbull" using  
> > the  
> > English analyzer (which stems words to root forms, lowercases, etc),  
> > you'd  
> > get an inverted index that looks somethinglike:
> > 
> > doug  
> > document: 1  
> > position 0  
> > freq 1  
> > turnbul  
> > document: 1  
> > position 1  
> > freq 1
> > 
> > A "term query" therefore directly accesses terms. Its a bit of a  
> > low-level  
> > concern. You'd have to query "doug" directly even though the original  
> > text  
> > said "dougie".
> > 
> > However, loosely people use the word "search term" to mean words people  
> > enter into a search bar.
> > 
> > "string" is a concept that just reflects the text being analyzed. IE  
> > "Dougie  
> > Turnbull". This type is at the Elasticsearch level, and is a peer for  
> > integer, floats, doubles etc. This type dicates how Elasticsearch  
> > understands the value passed from the client and converts it to the  
> > inverted  
> > index structure above. A string type will be analyzed, picked apart into  
> > terms, etc based on the associated analyzer. Other types like numeric  
> > types  
> > have other low-level magic that helps convert them to the inverted index  
> > data structure.
> > 
> > Hope that helps,  
> > -Doug
> > 
> > On Thu, Apr 23, 2015 at 10:42 AM, Jason Wee [peichieh@gmail.com](mailto:peichieh@gmail.com) wrote:
> > 
> > > Can anybody explain what is the different between term and string in  
> > > elasticsearch context?
> > > 
> > > When we index using default mapping  
> > > (  
> > > [Update mapping API | Elasticsearch Guide [8.11] | Elastic](http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html)  
> > > ),  
> > > the default type is string.
> > > 
> > > But when we query, we use the word term  
> > > (  
> > > [Term query | Elasticsearch Guide [8.11] | Elastic](http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html)  
> > > )  
> > > instead of string?
> > > 
> > > I google lucene documentation, the term is define as
> > > 
> > > A query is broken up into terms and operators. There are two types of  
> > > terms: Single Terms and Phrases. A Single Term is a single word such as  
> > > "test" or "hello". A Phrase is a group of words surrounded by double  
> > > quotes  
> > > such as "hello dolly".
> > > 
> > > but it has no mentioned on string.
> 
> [org.apache.lucene.queryparser.classic (Lucene 4.10.3 API)](https://lucene.apache.org/core/4_10_3/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package_description)
> 
> > > Thank you.
> > > 
> > > Jason
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups  
> > > "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an  
> > > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/df898132-f7f8-4476-8a81-21e3891dfb1a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/df898132-f7f8-4476-8a81-21e3891dfb1a%40googlegroups.com)  
> .
> 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > Doug Turnbull | Search Relevance Consultant | OpenSource Connections,  
> > LLC |  
> > 240.476.9983 | [http://www.opensourceconnections.com](http://www.opensourceconnections.com)  
> > Author: Taming Search from Manning Publications  
> > This e-mail and all contents, including attachments, is considered to be  
> > Company Confidential unless explicitly stated otherwise, regardless of  
> > whether attachments are marked as such.
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/CALG6HL8RtomqZ3tWxB%2BEN2q\_JHZmppGwzVw0HfPWJjTmzVNXCw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALG6HL8RtomqZ3tWxB%2BEN2q_JHZmppGwzVw0HfPWJjTmzVNXCw%40mail.gmail.com)  
> .
> 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAHO4ityjCw-gCnSHxOyrHTkW1%2B4U13JbPvbaxcF6aeCmw%3DPH3A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAHO4ityjCw-gCnSHxOyrHTkW1%2B4U13JbPvbaxcF6aeCmw%3DPH3A%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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: [July 6, 2017, 12:16am UTC](https://discuss.elastic.co/t/term-and-string/23378/5 "2017-07-06T00:16:06Z")

</div>


