# Returning substring in a GET request

**URL:** https://discuss.elastic.co/t/returning-substring-in-a-get-request/11056
**Category:** Elasticsearch
**Created:** [March 7, 2013, 1:57pm UTC](https://discuss.elastic.co/t/returning-substring-in-a-get-request/11056 "2013-03-07T13:57:48Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![Anurag](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anurag/32/2286_2.png) [@Anurag](https://discuss.elastic.co/u/Anurag)
#### Post date: [March 7, 2013, 1:57pm UTC](https://discuss.elastic.co/t/returning-substring-in-a-get-request/11056/1 "2013-03-07T13:57:48Z")

</div>

Hi!

I was wondering if there was a way to return a substring (with offset &  
count) on a field in a GET request? The problem I am hitting is, I have the  
ID of the document, but I only want to retrieve N number of bytes from M  
offset.

Anurag

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)
#### Post date: [March 7, 2013, 2:06pm UTC](https://discuss.elastic.co/t/returning-substring-in-a-get-request/11056/2 "2013-03-07T14:06:55Z")

</div>

there is no such thing that can do that currently.

simon

On Thursday, March 7, 2013 2:57:48 PM UTC+1, Anurag wrote:

> Hi!
> 
> I was wondering if there was a way to return a substring (with offset &  
> count) on a field in a GET request? The problem I am hitting is, I have the  
> ID of the document, but I only want to retrieve N number of bytes from M  
> offset.
> 
> Anurag

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Anurag](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anurag/32/2286_2.png) [@Anurag](https://discuss.elastic.co/u/Anurag)
#### Post date: [March 7, 2013, 2:26pm UTC](https://discuss.elastic.co/t/returning-substring-in-a-get-request/11056/3 "2013-03-07T14:26:41Z")

</div>

Thanks Simon. I'll then try and see if I can do it on the client side.

Anurag

On Thu, Mar 7, 2013 at 7:36 PM, simonw [simon.willnauer@elasticsearch.com](mailto:simon.willnauer@elasticsearch.com)wrote:

> there is no such thing that can do that currently.
> 
> simon
> 
> On Thursday, March 7, 2013 2:57:48 PM UTC+1, Anurag wrote:
> 
> > Hi!
> > 
> > I was wondering if there was a way to return a substring (with offset &  
> > count) on a field in a GET request? The problem I am hitting is, I have the  
> > ID of the document, but I only want to retrieve N number of bytes from M  
> > offset.
> > 
> > Anurag
> > 
> > --  
> > 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).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Anurag \<0xB20A82C1\>  
[http://web.gnuer.org/blog/](http://web.gnuer.org/blog/)

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![pellyadolfo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pellyadolfo/32/1879_2.png) [@pellyadolfo](https://discuss.elastic.co/u/pellyadolfo)
#### Post date: [January 3, 2014, 2:36am UTC](https://discuss.elastic.co/t/returning-substring-in-a-get-request/11056/4 "2014-01-03T02:36:21Z")

</div>

Hi, I have some quite large documents (about 30k) and I want to get only an _excerpt  
of each document_, for example, 250 characters. It really does not matter  
if they are the first 250 characters or a chunk in the middle. I would  
prefer not doing it a client side to avoid these large documents moving in  
the network. This thread looks very related.

Is there any progress on this (use a GET request) from March?

Can this be done with a preparedSearch or any other mechanism?

Looks something quite trivial to not have an easy response.

Thanks

--  
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/0248e2c2-e124-4775-ab5a-6cde5bca98d7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0248e2c2-e124-4775-ab5a-6cde5bca98d7%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)
#### Post date: [January 3, 2014, 2:49am UTC](https://discuss.elastic.co/t/returning-substring-in-a-get-request/11056/5 "2014-01-03T02:49:45Z")

</div>

On Thu, Jan 2, 2014 at 9:36 PM, Adolfo Rodriguez [pellyadolfo@yahoo.es](mailto:pellyadolfo@yahoo.es)wrote:

Hi, I have some quite large documents (about 30k) and I want to get  
only an \*excerpt

> of each document\*, for example, 250 characters. It really does not matter  
> if they are the first 250 characters or a chunk in the middle. I would  
> prefer not doing it a client side to avoid these large documents moving in  
> the network. This thread looks very related.
> 
> Is there any progress on this (use a GET request) from March?
> 
> Can this be done with a preparedSearch or any other mechanism?
> 
> Looks something quite trivial to not have an easy response.

Highlighting can return an excerpt from the beginning of the document if it  
doesn't find a match in the document. You can't do that with an HTTP GET.  
You still have to POST the search with the right highlihting configuration.

Nik

--  
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/CAPmjWd288v0%2BDNe0UJwqntnbUOJG%2Bjfgsq%2B2hpogWrUKY\_ZSbw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd288v0%2BDNe0UJwqntnbUOJG%2Bjfgsq%2B2hpogWrUKY_ZSbw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![pellyadolfo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pellyadolfo/32/1879_2.png) [@pellyadolfo](https://discuss.elastic.co/u/pellyadolfo)
#### Post date: [January 3, 2014, 3:12am UTC](https://discuss.elastic.co/t/returning-substring-in-a-get-request/11056/6 "2014-01-03T03:12:24Z")

</div>

Hi Nikolas, yes, thanks, this is exactly my use case, i.e. when  
highlighting does not match any term.

There seems to be something about this from 4 months ago:  
[https://github.com/elasticsearch/elasticsearch/pull/3613](https://github.com/elasticsearch/elasticsearch/pull/3613) It looks that  
config param was called no\_matches.

Any idea how to configure this with the Java API?

--  
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/97933a1f-8e42-4373-827d-9c2338461f06%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/97933a1f-8e42-4373-827d-9c2338461f06%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![pellyadolfo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pellyadolfo/32/1879_2.png) [@pellyadolfo](https://discuss.elastic.co/u/pellyadolfo)
#### Post date: [January 3, 2014, 4:21am UTC](https://discuss.elastic.co/t/returning-substring-in-a-get-request/11056/7 "2014-01-03T04:21:32Z")

</div>

This seems a very recent addition[https://github.com/elasticsearch/elasticsearch/commit/14a709f563a264c4371392e31c7bee9d26758056](https://github.com/elasticsearch/elasticsearch/commit/14a709f563a264c4371392e31c7bee9d26758056) to  
ES and the config param finally called no\_match\_size. It looks like that  
the way to define this is in a Highlighter Field as follows:

HighlightBuilder.Field field = new HighlightBuilder.Field("text")  
.fragmentSize(21)  
.numOfFragments(1)  
.highlighterType("plain")  
._noMatchSize(20);_

and, in the SearchRequestBuilder assign this field as follows:  
...  
.addHighlightedField(_field_)  
...

Unfortunately my ES 0\_90\_5, HighlightBuilder still does not contain this  
method noMatchSize  
[https://github.com/elasticsearch/elasticsearch/blob/14a709f563a264c4371392e31c7bee9d26758056/src/main/java/org/elasticsearch/search/highlight/HighlightBuilder.java#L455](https://github.com/elasticsearch/elasticsearch/blob/14a709f563a264c4371392e31c7bee9d26758056/src/main/java/org/elasticsearch/search/highlight/HighlightBuilder.java#L455)so  
it looks that I have to upgrade my ES to latest release.

To be confirmed....

Regards.

--  
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/3709de3c-1acf-4f4e-b71b-dbedd789e865%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3709de3c-1acf-4f4e-b71b-dbedd789e865%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![pellyadolfo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pellyadolfo/32/1879_2.png) [@pellyadolfo](https://discuss.elastic.co/u/pellyadolfo)
#### Post date: [January 3, 2014, 4:52am UTC](https://discuss.elastic.co/t/returning-substring-in-a-get-request/11056/8 "2014-01-03T04:52:44Z")

</div>

Functionality is available from 1.0.0.beta1[http://www.elasticsearch.org/downloads/1-0-0-beta1/](http://www.elasticsearch.org/downloads/1-0-0-beta1/)  
:

- New highlighter based on lucene postings highlighter #3704[http://github.com/elasticsearch/elasticsearch/issues/issue/3704](http://github.com/elasticsearch/elasticsearch/issues/issue/3704)  
, #4042 [http://github.com/elasticsearch/elasticsearch/issues/issue/4042](http://github.com/elasticsearch/elasticsearch/issues/issue/4042)  
& #4103[http://github.com/elasticsearch/elasticsearch/issues/issue/4103](http://github.com/elasticsearch/elasticsearch/issues/issue/4103)

and alternatively can be configured with .setHighlighterNoMatchSize(20) on  
the SearchRequestBuilder.

--  
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/40d1179b-b5d7-4676-b006-16dea7a7faf1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/40d1179b-b5d7-4676-b006-16dea7a7faf1%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![pellyadolfo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pellyadolfo/32/1879_2.png) [@pellyadolfo](https://discuss.elastic.co/u/pellyadolfo)
#### Post date: [January 3, 2014, 6:24am UTC](https://discuss.elastic.co/t/returning-substring-in-a-get-request/11056/9 "2014-01-03T06:24:37Z")

</div>

Tested with 1.0.0.beta1 but does not seem to be working.

For the query below, the highlights are returned successfully when the  
record matches _key_. However, despite \*setHighlighterNoMatchSize(250) \*has  
been set, unmatching records does not return 250 characters from the start  
of the record as expected.

return getClient().prepareSearch()  
.setQuery(QueryBuilders  
.boolQuery()  
.should(QueryBuilders.matchQuery("column", _key_))  
)  
.setFilter(FilterBuilders.idsFilter("vertex").ids(array))  
.addHighlightedField("column", 250, 1)

- .setHighlighterNoMatchSize(250)\*  
.execute()  
.actionGet();

Any idea?

Thanks

--  
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/5bd91dfd-5f96-4b63-aa86-6580b057e88b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5bd91dfd-5f96-4b63-aa86-6580b057e88b%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![pellyadolfo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pellyadolfo/32/1879_2.png) [@pellyadolfo](https://discuss.elastic.co/u/pellyadolfo)
#### Post date: [January 3, 2014, 6:42am UTC](https://discuss.elastic.co/t/returning-substring-in-a-get-request/11056/10 "2014-01-03T06:42:40Z")

</div>

Tested in 0.90.9 (December 23, 2013) as seems newer than 1.0.0.beta1 (November  
6, 2013) and same issue: no highlighting results when key does not match,  
despite _setHighlighterNoMatchSize(250) has been set._

--  
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/3079f257-81a1-40a3-9d21-337d53aa6571%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3079f257-81a1-40a3-9d21-337d53aa6571%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [January 3, 2014, 8:01am UTC](https://discuss.elastic.co/t/returning-substring-in-a-get-request/11056/11 "2014-01-03T08:01:46Z")

</div>

You must do this at client side.

Jörg

--  
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/CAKdsXoHQ\_6ebEjax-pjb66B1xuG-xVfTMd-49XG%2BatQkjF760A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHQ_6ebEjax-pjb66B1xuG-xVfTMd-49XG%2BatQkjF760A%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![pellyadolfo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pellyadolfo/32/1879_2.png) [@pellyadolfo](https://discuss.elastic.co/u/pellyadolfo)
#### Post date: [January 3, 2014, 5:02pm UTC](https://discuss.elastic.co/t/returning-substring-in-a-get-request/11056/12 "2014-01-03T17:02:37Z")

</div>

Can you please elaborate a bit? Will this be available in future releases?

On Friday, 3 January 2014 03:01:46 UTC-5, Jörg Prante wrote:

> You must do this at client side.
> 
> Jörg

--  
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/278fd6a8-44bf-4da8-af9f-d966988e8463%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/278fd6a8-44bf-4da8-af9f-d966988e8463%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:58am UTC](https://discuss.elastic.co/t/returning-substring-in-a-get-request/11056/13 "2017-07-06T01:58:28Z")

</div>


