# Span first queries

**URL:** <https://discuss.elastic.co/t/span-first-queries/17913>\
**Category:** Elasticsearch\
**Created:** [June 4, 2014, 8:37pm UTC](https://discuss.elastic.co/t/span-first-queries/17913 "2014-06-04T20:37:51Z")\
**Posts on this page:** 3\
**Page:** 1

<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:** [June 4, 2014, 8:37pm UTC](https://discuss.elastic.co/t/span-first-queries/17913/1 "2014-06-04T20:37:51Z")

</div>

Is there a way to perform a span\_first query against a query\_string or  
match query? I'd like to use this in a rescore to improve relevance.

If I can't do that I'll have to do something silly like create another  
field pre-chopped on the way into Elasticsearch.

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/CAPmjWd124LZ25Kc0cvoSpjkSc3-2nrq4FVk1MrqmFvp%3DxW%3DJug%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd124LZ25Kc0cvoSpjkSc3-2nrq4FVk1MrqmFvp%3DxW%3DJug%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [June 4, 2014, 9:06pm UTC](https://discuss.elastic.co/t/span-first-queries/17913/2 "2014-06-04T21:06:55Z")

</div>

The limitation of only able to use term queries comes from Lucene. I never  
looked into why there is such a limitation in Lucene, but since they have a  
lot of smart people working on the code, I assume there must be a good  
reason. 🙂 Phrase queries do not have such a limitation.

I use span queries a lot where I require phrase queries with in order  
terms. I pre-analyzed my queries by instantiating an AnalysisService  
locally, which is only doable if using the Java API. Hackish, but it works.  
Ultimately I need to move away from span queries.

Cheers,

Ivan

On Wed, Jun 4, 2014 at 1:37 PM, Nikolas Everett [nik9000@gmail.com](mailto:nik9000@gmail.com) wrote:

> Is there a way to perform a span\_first query against a query\_string or  
> match query? I'd like to use this in a rescore to improve relevance.
> 
> If I can't do that I'll have to do something silly like create another  
> field pre-chopped on the way into Elasticsearch.
> 
> 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/CAPmjWd124LZ25Kc0cvoSpjkSc3-2nrq4FVk1MrqmFvp%3DxW%3DJug%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd124LZ25Kc0cvoSpjkSc3-2nrq4FVk1MrqmFvp%3DxW%3DJug%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CAPmjWd124LZ25Kc0cvoSpjkSc3-2nrq4FVk1MrqmFvp%3DxW%3DJug%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd124LZ25Kc0cvoSpjkSc3-2nrq4FVk1MrqmFvp%3DxW%3DJug%40mail.gmail.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/CALY%3DcQBOv7d5\_yg0ei0Z%3DbE-oL-Ghxa-dMrV8Qqk09OT9TPTAQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQBOv7d5_yg0ei0Z%3DbE-oL-Ghxa-dMrV8Qqk09OT9TPTAQ%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:24am UTC](https://discuss.elastic.co/t/span-first-queries/17913/3 "2017-07-06T01:24:40Z")

</div>


