# Array of strings vs string

**URL:** https://discuss.elastic.co/t/array-of-strings-vs-string/17049
**Category:** Elasticsearch
**Created:** [April 16, 2014, 12:53pm UTC](https://discuss.elastic.co/t/array-of-strings-vs-string/17049 "2014-04-16T12:53:28Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Aleh\_Aleshka](https://avatars.discourse-cdn.com/v4/letter/a/4bbf92/32.png) [@Aleh\_Aleshka](https://discuss.elastic.co/u/Aleh_Aleshka)
#### Post date: [April 16, 2014, 12:53pm UTC](https://discuss.elastic.co/t/array-of-strings-vs-string/17049/1 "2014-04-16T12:53:28Z")

</div>

Hi

i'd like to have a field in document to which i'm going to append  
strings and use span\_near queries to search for a specific sequence of  
strings in it  
i wonder if that kind of usage makes sense, and if using array of  
strings instead of one long string would be better?

i.e.  
which document is better for this kind of query

|  
GET /my\_index/\_search  
{  
"query":{  
"span\_near":{  
"clauses":[  
{  
"span\_term":{  
"seq":"lolrof"  
}  
}

,{  
"span\_multi":{  
"match":{  
"regexp":{"seq":"000200\<0-20003\>"}  
}  
}  
}  
],  
"slop":100500,  
"in\_order":true  
}  
}  
}

|

and this kind of update:

|  
POST /my\_index/4aeN2WBSS8WIpUpplUryPg/\_update  
{  
"script":"ctx.\_source.seq += ['tag']"  
}

|

documents:

|  
POST /my\_index  
{  
"seq":["lolrofl","000100010001","000200020002"]  
}

|  
POST /my\_index  
{  
"seq":"lolrofl 000100010001 000200020002"  
}

|  
|

Thanks, Aleh

--  
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/534E7D48.407%40gmail.com](https://groups.google.com/d/msgid/elasticsearch/534E7D48.407%40gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)
#### Post date: [April 16, 2014, 3:39pm UTC](https://discuss.elastic.co/t/array-of-strings-vs-string/17049/2 "2014-04-16T15:39:00Z")

</div>

Hello Aleh ,

Both should be good for your purpose.

But then if you want to match against "abc def" ( that is with the space)  
tomorrow , the array type will alone help.  
You can disable the analyzer for the field and achieve the functionality  
which you cant if its a normal string.

Thanks  
Vineeth

On Wed, Apr 16, 2014 at 6:23 PM, Aleh Aleshka [oleglbch@gmail.com](mailto:oleglbch@gmail.com) wrote:

> Hi
> 
> i'd like to have a field in document to which i'm going to append strings  
> and use span\_near queries to search for a specific sequence of strings in it  
> i wonder if that kind of usage makes sense, and if using array of strings  
> instead of one long string would be better?
> 
> i.e.  
> which document is better for this kind of query
> 
> GET /my\_index/\_search  
> {  
> "query": {  
> "span\_near": {  
> "clauses": [  
> {  
> "span\_term": {  
> "seq" : "lolrof"  
> }  
> }
> 
> ```
> ,{
> "span_multi": {
> "match": {
> "regexp": {"seq" : "000200<0-20003>"}
> }
> }
> }
> ],
> "slop": 100500,
> "in_order": true
> }
> 
> ```
> 
> }  
> }
> 
> and this kind of update:
> 
> POST /my\_index/4aeN2WBSS8WIpUpplUryPg/\_update  
> {  
> "script" : "ctx.\_source.seq += ['tag']"  
> }
> 
> documents:
> 
> POST /my\_index  
> {  
> "seq": ["lolrofl","000100010001","000200020002"]  
> }
> 
> POST /my\_index  
> {  
> "seq": "lolrofl 000100010001 000200020002"  
> }
> 
> Thanks, Aleh
> 
> --  
> 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/534E7D48.407%40gmail.com](https://groups.google.com/d/msgid/elasticsearch/534E7D48.407%40gmail.com)[https://groups.google.com/d/msgid/elasticsearch/534E7D48.407%40gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/534E7D48.407%40gmail.com?utm_medium=email&utm_source=footer)  
> .  
> 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/CAGdPd5kFt0ABgY6P7%3Dae3z2fDXfByWEFjrPDzyAduXCMVA%3DQZA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5kFt0ABgY6P7%3Dae3z2fDXfByWEFjrPDzyAduXCMVA%3DQZA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Aleh\_Aleshka](https://avatars.discourse-cdn.com/v4/letter/a/4bbf92/32.png) [@Aleh\_Aleshka](https://discuss.elastic.co/u/Aleh_Aleshka)
#### Post date: [April 17, 2014, 12:42pm UTC](https://discuss.elastic.co/t/array-of-strings-vs-string/17049/3 "2014-04-17T12:42:28Z")

</div>

Thanks!

On Wednesday, April 16, 2014 6:39:00 PM UTC+3, vineeth mohan wrote:

> Hello Aleh ,
> 
> Both should be good for your purpose.
> 
> But then if you want to match against "abc def" ( that is with the space)  
> tomorrow , the array type will alone help.  
> You can disable the analyzer for the field and achieve the functionality  
> which you cant if its a normal string.
> 
> Thanks  
> Vineeth
> 
> On Wed, Apr 16, 2014 at 6:23 PM, Aleh Aleshka \<[oleg...@gmail.com](mailto:oleg...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hi
> > 
> > i'd like to have a field in document to which i'm going to append strings  
> > and use span\_near queries to search for a specific sequence of strings in it  
> > i wonder if that kind of usage makes sense, and if using array of strings  
> > instead of one long string would be better?
> > 
> > i.e.  
> > which document is better for this kind of query
> > 
> > GET /my\_index/\_search  
> > {  
> > "query": {  
> > "span\_near": {  
> > "clauses": [  
> > {  
> > "span\_term": {  
> > "seq" : "lolrof"  
> > }  
> > }
> > 
> > ```
> > ,{
> > "span_multi": {
> > "match": {
> > "regexp": {"seq" : "000200<0-20003>"}
> > }
> > }
> > }
> > ],
> > "slop": 100500,
> > "in_order": true
> > }
> > 
> > ```
> > 
> > }  
> > }
> > 
> > and this kind of update:
> > 
> > POST /my\_index/4aeN2WBSS8WIpUpplUryPg/\_update  
> > {  
> > "script" : "ctx.\_source.seq += ['tag']"  
> > }
> > 
> > documents:
> > 
> > POST /my\_index  
> > {  
> > "seq": ["lolrofl","000100010001","000200020002"]  
> > }
> > 
> > POST /my\_index  
> > {  
> > "seq": "lolrofl 000100010001 000200020002"  
> > }
> > 
> > Thanks, Aleh
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/534E7D48.407%40gmail.com](https://groups.google.com/d/msgid/elasticsearch/534E7D48.407%40gmail.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/1fcaee3c-aa5b-4e59-8189-82ff46eb770f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1fcaee3c-aa5b-4e59-8189-82ff46eb770f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [April 20, 2014, 11:58am UTC](https://discuss.elastic.co/t/array-of-strings-vs-string/17049/4 "2014-04-20T11:58:22Z")

</div>

Also have a read about position\_offset\_gap:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

On 17 April 2014 14:42, Aleh Aleshka [oleglbch@gmail.com](mailto:oleglbch@gmail.com) wrote:

> Thanks!
> 
> On Wednesday, April 16, 2014 6:39:00 PM UTC+3, vineeth mohan wrote:
> 
> > Hello Aleh ,
> > 
> > Both should be good for your purpose.
> > 
> > But then if you want to match against "abc def" ( that is with the space)  
> > tomorrow , the array type will alone help.  
> > You can disable the analyzer for the field and achieve the functionality  
> > which you cant if its a normal string.
> > 
> > Thanks  
> > Vineeth
> > 
> > On Wed, Apr 16, 2014 at 6:23 PM, Aleh Aleshka [oleg...@gmail.com](mailto:oleg...@gmail.com) wrote:
> > 
> > > Hi
> > > 
> > > i'd like to have a field in document to which i'm going to append  
> > > strings and use span\_near queries to search for a specific sequence of  
> > > strings in it  
> > > i wonder if that kind of usage makes sense, and if using array of  
> > > strings instead of one long string would be better?
> > > 
> > > i.e.  
> > > which document is better for this kind of query
> > > 
> > > GET /my\_index/\_search  
> > > {  
> > > "query": {  
> > > "span\_near": {  
> > > "clauses": [  
> > > {  
> > > "span\_term": {  
> > > "seq" : "lolrof"  
> > > }  
> > > }
> > > 
> > > ```
> > > ,{
> > > "span_multi": {
> > > "match": {
> > > "regexp": {"seq" : "000200<0-20003>"}
> > > }
> > > }
> > > }
> > > ],
> > > "slop": 100500,
> > > "in_order": true
> > > }
> > > 
> > > ```
> > > 
> > > }  
> > > }
> > > 
> > > and this kind of update:
> > > 
> > > POST /my\_index/4aeN2WBSS8WIpUpplUryPg/\_update  
> > > {  
> > > "script" : "ctx.\_source.seq += ['tag']"  
> > > }
> > > 
> > > documents:
> > > 
> > > POST /my\_index  
> > > {  
> > > "seq": ["lolrofl","000100010001","000200020002"]  
> > > }
> > > 
> > > POST /my\_index  
> > > {  
> > > "seq": "lolrofl 000100010001 000200020002"  
> > > }
> > > 
> > > Thanks, Aleh
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > 
> > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > msgid/elasticsearch/534E7D48.407%[40gmail.com](http://40gmail.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/1fcaee3c-aa5b-4e59-8189-82ff46eb770f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1fcaee3c-aa5b-4e59-8189-82ff46eb770f%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/1fcaee3c-aa5b-4e59-8189-82ff46eb770f%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/1fcaee3c-aa5b-4e59-8189-82ff46eb770f%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> 
> 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/CAPt3XKSeQ3p%2B%2BQSpTDma4M1kzt2BGJEDUJq\_3GZRR0\_XEjmFYQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKSeQ3p%2B%2BQSpTDma4M1kzt2BGJEDUJq_3GZRR0_XEjmFYQ%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, 1:34am UTC](https://discuss.elastic.co/t/array-of-strings-vs-string/17049/5 "2017-07-06T01:34:47Z")

</div>


