How to filter facet result with a prefix

Hello,

I would like to get data in order to feed a auto-complete / suggest
component.
I tried the following query, but i don't succeed to get only prefixed facet
terms.

Any idea ?

Thanks

{

"size" : 10,

"query" : {

"query_string" : {

  "query" : "sam",

  "fields" : [ "title.edge_ngram_front" ]

}

},

"min_score" : 0.5,

"facets" : {

"sugguest" : {

  "terms" : {

    "field" : "title.shingle",

    "size" : 6

  },

  "facet_filter" : {

    "prefix" : {

      "term" : "sam"

    }

  }

}

}

}

--

Hello Antoine,

I think the problem is that you put the facet_filter under "facets",
instead of under the "sugguest", which is your facet name. This way,
you get results from the defined facet without the filter applied, and
then a count of your facet_filter matches.

Something like this should work as you expect it:

"facets": {
"suggest": {
"terms": {
"field": "field_name"
},
"size": 6,
"facet_filter": {
"query": {
"prefix": {
"field_name": "sam"
}
}
}
}
}

Best regards,
Radu

http://sematext.com/ -- Elasticsearch -- Solr -- Lucene

On Tue, Oct 23, 2012 at 3:14 PM, Antoine Véret antoine.veret@gmail.com wrote:

Hello,

I would like to get data in order to feed a auto-complete / suggest
component.
I tried the following query, but i don't succeed to get only prefixed facet
terms.

Any idea ?

Thanks

{

"size" : 10,

"query" : {

"query_string" : {

  "query" : "sam",

  "fields" : [ "title.edge_ngram_front" ]

}

},

"min_score" : 0.5,

"facets" : {

"sugguest" : {

  "terms" : {

    "field" : "title.shingle",

    "size" : 6

  },

  "facet_filter" : {

    "prefix" : {

      "term" : "sam"

    }

  }

}

}

}

--