# Return fragment when no query defined

**URL:** https://discuss.elastic.co/t/return-fragment-when-no-query-defined/11090
**Category:** Elasticsearch
**Created:** [March 10, 2013, 9:17pm UTC](https://discuss.elastic.co/t/return-fragment-when-no-query-defined/11090 "2013-03-10T21:17:06Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![milosz\_skurowski](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@milosz\_skurowski](https://discuss.elastic.co/u/milosz_skurowski)
#### Post date: [March 10, 2013, 9:17pm UTC](https://discuss.elastic.co/t/return-fragment-when-no-query-defined/11090/1 "2013-03-10T21:17:06Z")

</div>

Hi,

iam looking for solution to get fragment returned by ES (so solution same  
as highlight delivers) but i define query as match\_all.

Any idea how to get it?  
Thx in advance.

Milosz

--  
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: ![Rafal\_Kuc\_3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafal_kuc_3/32/799_2.png) [@Rafal\_Kuc\_3](https://discuss.elastic.co/u/Rafal_Kuc_3)
#### Post date: [March 10, 2013, 9:21pm UTC](https://discuss.elastic.co/t/return-fragment-when-no-query-defined/11090/2 "2013-03-10T21:21:32Z")

</div>

Hello!

Could you be more specific what you would like to get from ElasticSearch ? In case of match\_all query, you are basically saying, that you are interested in all the documents and not any particular data.

_--_

Regards,

Rafał Kuć

Sematext :: [http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - Nutch - ElasticSearch_

Hi,

iam looking for solution to get fragment returned by ES (so solution same as highlight delivers) but i define query as match\_all.

Any idea how to get it?

Thx in advance.

Milosz

--

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: ![milosz\_skurowski](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@milosz\_skurowski](https://discuss.elastic.co/u/milosz_skurowski)
#### Post date: [March 10, 2013, 10:17pm UTC](https://discuss.elastic.co/t/return-fragment-when-no-query-defined/11090/3 "2013-03-10T22:17:37Z")

</div>

Hi,

i search in field 'description' with term X (set up 100 chars highlight).  
In no search query X is defined i would like to get same lenght (fragment)  
of description returned instead of full description.

On Sunday, March 10, 2013 10:21:32 PM UTC+1, Rafał Kuć wrote:

> Hello!
> 
> Could you be more specific what you would like to get from Elasticsearch ?  
> In case of match\_all query, you are basically saying, that you are  
> interested in all the documents and not any particular data.
> 
> \*--  
> Regards,  
> Rafał Kuć  
> Sematext :: _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch -  
> Elasticsearch
> 
> - 
> 
> Hi,
> 
> iam looking for solution to get fragment returned by ES (so solution same  
> as highlight delivers) but i define query as match\_all.
> 
> Any idea how to get it?  
> Thx in advance.
> 
> ## Milosz
> 
> 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:\>.  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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: ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)
#### Post date: [March 11, 2013, 5:44am UTC](https://discuss.elastic.co/t/return-fragment-when-no-query-defined/11090/4 "2013-03-11T05:44:10Z")

</div>

Hi

there are couple of options you can try.

a) if you did not disable \_source field then you can get the whole field  
content from it, for example you could use fields [1]  
b) If your 'description' field is too long and you need to make it shorter  
then you can either post-process it at the client side or try to use script  
field [2]

What we do is that for each document we have a 'description' field that is  
used in similar use case (i.e. query does not match any of fields that are  
used to produce highlights). When users push documents into the search  
server they can setup the 'description' field and they know that this value  
will be used (i.e. displayed) if no highlights are created. So it is  
something like a _pitch_ field 🙂 and we get this field using 'fields' [1]  
while the 'description' field is stored.

Regards,  
Lukas

[1] [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/fields.html)(not  
that if \_source is not enabled then you need to store particular  
fields that you want to return)  
[2]  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/script-fields.html)

On Sun, Mar 10, 2013 at 11:17 PM, milosz skurowski [skurowski@gmail.com](mailto:skurowski@gmail.com)wrote:

> Hi,
> 
> i search in field 'description' with term X (set up 100 chars highlight).  
> In no search query X is defined i would like to get same lenght (fragment)  
> of description returned instead of full description.
> 
> On Sunday, March 10, 2013 10:21:32 PM UTC+1, Rafał Kuć wrote:
> 
> > Hello!
> > 
> > Could you be more specific what you would like to get from Elasticsearch  
> > ? In case of match\_all query, you are basically saying, that you are  
> > interested in all the documents and not any particular data.
> > 
> > \*--  
> > Regards,  
> > Rafał Kuć  
> > Sematext :: _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch -  
> > Elasticsearch
> > 
> > - 
> > 
> > Hi,
> > 
> > iam looking for solution to get fragment returned by ES (so solution same  
> > as highlight delivers) but i define query as match\_all.
> > 
> > Any idea how to get it?  
> > Thx in advance.
> > 
> > ## Milosz
> > 
> > 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](http://googlegroups.com).  
> > For more options, visit [https://groups.google](https://groups.google).\*\*com/groups/opt\_out[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > .
> 
> --  
> 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).

--  
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: ![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, 2:47am UTC](https://discuss.elastic.co/t/return-fragment-when-no-query-defined/11090/5 "2017-07-06T02:47:19Z")

</div>


