Returning substring in a GET request


(Anurag) #1

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.
For more options, visit https://groups.google.com/groups/opt_out.


(simonw-2) #2

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.
For more options, visit https://groups.google.com/groups/opt_out.


(Anurag) #3

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.comwrote:

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.
For more options, visit https://groups.google.com/groups/opt_out.

--
Anurag <0xB20A82C1>
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.
For more options, visit https://groups.google.com/groups/opt_out.


(pellyadolfo) #4

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.
To view this discussion on the web visit 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.


(Nik Everett) #5

On Thu, Jan 2, 2014 at 9:36 PM, Adolfo Rodriguez pellyadolfo@yahoo.eswrote:

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.
To view this discussion on the web visit 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.


(pellyadolfo) #6

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 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.
To view this discussion on the web visit 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.


(pellyadolfo) #7

This seems a very recent additionhttps://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#L455so
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.
To view this discussion on the web visit 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.


(pellyadolfo) #8

Functionality is available from 1.0.0.beta1http://www.elasticsearch.org/downloads/1-0-0-beta1/
:

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.
To view this discussion on the web visit 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.


(pellyadolfo) #9

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.
To view this discussion on the web visit 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.


(pellyadolfo) #10

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.
To view this discussion on the web visit 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.


(Jörg Prante) #11

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.
To view this discussion on the web visit 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.


(pellyadolfo) #12

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.
To view this discussion on the web visit 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.


(system) #13