# Span Near Query is not working for me

**URL:** <https://discuss.elastic.co/t/span-near-query-is-not-working-for-me/21172>\
**Category:** Elasticsearch\
**Created:** [December 9, 2014, 10:37pm UTC](https://discuss.elastic.co/t/span-near-query-is-not-working-for-me/21172 "2014-12-09T22:37:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xiaolong\_Jiang](https://avatars.discourse-cdn.com/v4/letter/x/49beb7/32.png) [@Xiaolong\_Jiang](https://discuss.elastic.co/u/Xiaolong_Jiang)\
**Post date:** [December 9, 2014, 10:37pm UTC](https://discuss.elastic.co/t/span-near-query-is-not-working-for-me/21172/1 "2014-12-09T22:37:43Z")

</div>

I have below script to test span near query

#!/bin/bash

curl -XPUT 'ourhost/xiaolongindexername/'

curl -XPUT 'ourhost/xiaolongindexername/xiaolongindexertype/1' -d '{

```
"company":"Safari Books Online"

}'

```

#test match query to make sure index is inserted properly

curl -XGET 'ourhost/xiaolongindexername/xiaolongindexertype/\_search' -d  
'{"query": {"match":{"company":"safari"}}}'

curl -XGET 'ourhost/xiaolongindexername/xiaolongindexertype/\_search' -d '{  
"query": { "span\_near" : {"clauses" : [ {"span\_term" : {"company" :  
"Safari"}}, {"span\_term" : {"company" : "Books"}}, {"span\_term" : {  
"company" : "Online" } } ],"slop" : 100,"in\_order" :  
false,"collect\_payloads" : false } } }'

I can get result for match query but not for span query.

Does anyone have any clue?

Thanks,

Xiaolong

--  
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/87c7a904-f017-431f-925b-8f5830aeeccc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/87c7a904-f017-431f-925b-8f5830aeeccc%40googlegroups.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, 12:44am UTC](https://discuss.elastic.co/t/span-near-query-is-not-working-for-me/21172/2 "2017-07-06T00:44:39Z")

</div>


