The end parameter is too low. It needs to be at a minimum the number of clauses in the span_near query.
-- Ivan On Mon, Apr 28, 2014 at 7:05 PM, chee hoo lum <[email protected]> wrote: > Hi Ivan, > > Not able to get any result with the following query : > > { > "from" : 100, > "size" : 100, > "query" : { > "span_first" : { > "match" : { > "span_near" : { > "clauses" : [ > { "span_term" : { "DISPLAY_NAME" : "happy" } }, > { "span_term" : { "DISPLAY_NAME" : "people" } } > > ], > "slop" : 1, > "in_order" : true > } > }, > "end" : 1 > } > } > } > > > Meanwhile tried with : > > { > "from" : 100, > "size" : 100, > "query" : { > "span_first" : { > "match" : { > "span_term" : { "DISPLAY_NAME" : "happy" } > }, > "end" : 1 > } > } > } > > and it returns : > > "_index": "jdbc_dev", > "_type": "media", > "_id": "9556", > "_score": 4.612431, > "_source": { > "DISPLAY_NAME": "Happy People", > > > Anything wrong with my first query ? > > Thanks > > > > On Tue, Apr 29, 2014 at 12:16 AM, Ivan Brusic <[email protected]> wrote: > >> The main limitation of the span queries is that they only operate on >> analyzed terms. The terms used in span_term must match the terms in the >> index. In your case, there is no single term "happy holiday" in your index, >> because the original document was tokenized into "happy" "birthday" "to" >> "you". >> >> You would need to do a span near query of the two terms with a slop of 1 >> and in order. This span near query will then be the argument to the span >> first. >> >> Here is a good explanation of span queries in Lucene: >> http://searchhub.org/2009/07/18/the-spanquery/ >> >> -- >> Ivan >> >> >> On Sun, Apr 27, 2014 at 11:24 PM, cyrilforce <[email protected]>wrote: >> >>> Hi Ivan, >>> >>> I recreate the mapping and re-index the documents and now working fine. >>> Thanks. >>> >>> Btw would like to ask how i could search two or more words in the >>> span_first query as i need it to support the following searches : >>> 1)happy >>> 2)happy holiday >>> 3)happy birthday to you >>> >>> { >>> "from" : 100, >>> "size" : 100, >>> "query" : { >>> "span_first" : { >>> "match" : { >>> * "span_term" : { "DISPLAY_NAME" : "happy holiday" }* >>> }, >>> "end" : 1 >>> } >>> } >>> } >>> >>> >>> returns empty list even we have documents that display_name start with >>> *happy >>> holiday*. >>> >>> Thanks. >>> >>> >>> On Sunday, April 27, 2014 2:55:37 AM UTC+8, cyrilforce wrote: >>>> >>>> Hi Ivan, >>>> >>>> I am using version elasticsearch-0.90.1. Nope we don't have any >>>> templates. Not sure whether your are referring to the full index mapping >>>> here's the gist >>>> >>>> media mapping >>>> https://gist.github.com/cheehoo/11327970 >>>> >>>> full index mapping >>>> https://gist.github.com/cheehoo/11327996 >>>> >>>> Thanks in advance. >>>> >>>> >>>> >>>> >>>> >>>> On Sat, Apr 26, 2014 at 8:31 AM, Ivan Brusic <[email protected]> wrote: >>>> >>>>> Your mapping looks correct. Which version are you running? Do you have >>>>> any templates? >>>>> >>>>> Just to be on the safe side, can you provide the mapping that >>>>> Elasticsearch is using (not the one you provide): >>>>> >>>>> http://localhost:9200/jdbc_dev/media/_mapping >>>>> >>>>> -- >>>>> Ivan >>>>> >>>>> >>>>> >>>>> >>>>> On Fri, Apr 25, 2014 at 3:24 AM, cyrilforce <[email protected]>wrote: >>>>> >>>>>> Hi, >>>>>> >>>>>> I am trying to query some records via the span_first query as below : >>>>>> >>>>>> { >>>>>> "from" : 100, >>>>>> "size" : 100, >>>>>> "query" : { >>>>>> "span_first" : { >>>>>> "match" : { >>>>>> * "span_term" : { "DISPLAY_NAME" : "happy" }* >>>>>> }, >>>>>> "end" : 1 >>>>>> } >>>>>> } >>>>>> } >>>>>> >>>>>> >>>>>> >>>>>> however it returned me with an error : >>>>>> >>>>>> "index": "jdbc_dev", >>>>>> "shard": 4, >>>>>> "status": 500, >>>>>> * "reason": >>>>>> "RemoteTransportException[[portal-web-02][inet[/192.168.96.27:9300]][search/phase/query/id]]; >>>>>> nested: QueryPhaseExecutionException[[jdbc_dev][4]: >>>>>> query[filtered(spanFirst(DISPLAY_NAME:happy, >>>>>> 1))->cache(_type:media)],from[100],size[100]: Query Failed [Failed to >>>>>> execute main query]]; nested: IllegalStateException[field >>>>>> \"DISPLAY_NAME\" >>>>>> was indexed without position data; cannot run SpanTermQuery >>>>>> (term=happy)]; >>>>>> "* >>>>>> } >>>>>> >>>>>> >>>>>> >>>>>> The mapping for that type : >>>>>> >>>>>> { >>>>>> "media": { >>>>>> "properties": { >>>>>> "AUDIO": { >>>>>> "type": "string" >>>>>> }, >>>>>> "BILLINGTYPE_ID": { >>>>>> "type": "long" >>>>>> }, >>>>>> "CATMEDIA_CDATE": { >>>>>> "type": "date", >>>>>> "format": "dateOptionalTime" >>>>>> }, >>>>>> "CATMEDIA_NAME": { >>>>>> "type": "string" >>>>>> }, >>>>>> "CATMEDIA_RANK": { >>>>>> "type": "long" >>>>>> }, >>>>>> "CAT_ID": { >>>>>> "type": "long" >>>>>> }, >>>>>> "CAT_NAME": { >>>>>> "type": "string", >>>>>> "analyzer": "string_lowercase", >>>>>> "include_in_all": true >>>>>> }, >>>>>> "CAT_PARENT": { >>>>>> "type": "long" >>>>>> }, >>>>>> "CHANNEL_ID": { >>>>>> "type": "long" >>>>>> }, >>>>>> "CKEY": { >>>>>> "type": "long" >>>>>> }, >>>>>> * "DISPLAY_NAME": {* >>>>>> * "type": "string",* >>>>>> * "analyzer": "standard"* >>>>>> * },* >>>>>> "FTID": { >>>>>> "type": "string" >>>>>> }, >>>>>> "GENRE": { >>>>>> "type": "string" >>>>>> }, >>>>>> "ITEMCODE": { >>>>>> "type": "string" >>>>>> }, >>>>>> "KEYWORDS": { >>>>>> "type": "string" >>>>>> }, >>>>>> "LANG_ID": { >>>>>> "type": "long" >>>>>> }, >>>>>> "LONG_DESCRIPTION": { >>>>>> "type": "string" >>>>>> }, >>>>>> "MAPPINGS": { >>>>>> "type": "string", >>>>>> "analyzer": "string_lowercase", >>>>>> "include_in_all": true >>>>>> }, >>>>>> "MEDIA_ID": { >>>>>> "type": "long" >>>>>> }, >>>>>> "MEDIA_PKEY": { >>>>>> "type": "string" >>>>>> }, >>>>>> "PERFORMER": { >>>>>> "type": "string" >>>>>> }, >>>>>> "PLAYER": { >>>>>> "type": "string" >>>>>> }, >>>>>> "POSITION": { >>>>>> "type": "long" >>>>>> }, >>>>>> "PRICE": { >>>>>> "type": "double" >>>>>> }, >>>>>> "PRIORITY": { >>>>>> "type": "long" >>>>>> }, >>>>>> "SHORTCODE": { >>>>>> "type": "string" >>>>>> }, >>>>>> "SHORT_DESCRIPTION": { >>>>>> "type": "string" >>>>>> }, >>>>>> "TYPE_ID": { >>>>>> "type": "long" >>>>>> }, >>>>>> "VIEW_ID": { >>>>>> "type": "long" >>>>>> } >>>>>> } >>>>>> } >>>>>> } >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> I would like to know what is the reason and how i could fix it. >>>>>> 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 [email protected]. >>>>>> >>>>>> To view this discussion on the web visit https://groups.google.com/d/ >>>>>> msgid/elasticsearch/ad8740af-2038-40d4-9fc2-79d6e1402e5a% >>>>>> 40googlegroups.com<https://groups.google.com/d/msgid/elasticsearch/ad8740af-2038-40d4-9fc2-79d6e1402e5a%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>> . >>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>> >>>>> >>>>> -- >>>>> You received this message because you are subscribed to a topic in the >>>>> Google Groups "elasticsearch" group. >>>>> To unsubscribe from this topic, visit https://groups.google.com/d/ >>>>> topic/elasticsearch/cwzQrR1Rpsw/unsubscribe. >>>>> To unsubscribe from this group and all its topics, send an email to >>>>> [email protected]. >>>>> To view this discussion on the web visit https://groups.google.com/d/ >>>>> msgid/elasticsearch/CALY%3DcQBYhpWDHm-h-1rXFO% >>>>> 3DvHY0y4qkHdcHrR57nGEc0f1haAw%40mail.gmail.com<https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQBYhpWDHm-h-1rXFO%3DvHY0y4qkHdcHrR57nGEc0f1haAw%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> >>>> >>>> -- >>>> Regards, >>>> >>>> Chee Hoo >>>> >>> -- >>> 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 [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/elasticsearch/c6d86b5e-52c9-479d-b2fa-78ef9f8bde0d%40googlegroups.com<https://groups.google.com/d/msgid/elasticsearch/c6d86b5e-52c9-479d-b2fa-78ef9f8bde0d%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "elasticsearch" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/elasticsearch/cwzQrR1Rpsw/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQBefd__MOrWNUzHvTdkk8ZtMD1BxHAB26Cxz3k3OSYSAQ%40mail.gmail.com<https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQBefd__MOrWNUzHvTdkk8ZtMD1BxHAB26Cxz3k3OSYSAQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Regards, > > Chee Hoo > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elasticsearch/CAGS0%2Bg9iuY_eHFO_VUywCQYB18FOWprT%3D9ZBDm4id8A0brq0Pw%40mail.gmail.com<https://groups.google.com/d/msgid/elasticsearch/CAGS0%2Bg9iuY_eHFO_VUywCQYB18FOWprT%3D9ZBDm4id8A0brq0Pw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQBrN1ft3kG_L_LZ39KF-L1Y7hBsPFy%3D2ar64%3DqKe3ogLw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
