Regexp Filter boost

Hello,

I'm trying to figure out if it's possible to boost hits based on a regexp.
For example, searching through records with user's names, I'd like to boost
those that start with the query. I've tried a query like the following but
it doesn't work like I'd like:

{
"query": {
"function_score": {
"functions": [
{
"boost_factor": 2,
"filter": {
"regexp": {
"name_not_analyzed": "^frank.*"
}
}
}
],
"score_mode": "multiply",
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "frank",
"default_operator": "AND"
}
},
{
"term": {
"site_id": {
"term": 1
}
}
}
]
}
}
}
}
}

Is this possible? If so, how? 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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/8bb66f5f-7b98-4c22-b9d1-1254fa768ab4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I think I've figured out another way to do what I want. This seems to work:

{
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "frank",
"default_operator": "AND"
}
},
{
"term": {
"site_id": {
"term": 1
}
}
}
],
"should": [
{
"match_phrase_prefix": {
"name": {
"query": "frank",
"max_expansions": 5
}
}
}
]
}
}
}

when using the analyzer as explained in

On Monday, January 19, 2015 at 12:13:42 PM UTC-5, Michael Irwin wrote:

Hello,

I'm trying to figure out if it's possible to boost hits based on a regexp.
For example, searching through records with user's names, I'd like to boost
those that start with the query. I've tried a query like the following
but it doesn't work like I'd like:

{
"query": {
"function_score": {
"functions": [
{
"boost_factor": 2,
"filter": {
"regexp": {
"name_not_analyzed": "^frank.*"
}
}
}
],
"score_mode": "multiply",
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "frank",
"default_operator": "AND"
}
},
{
"term": {
"site_id": {
"term": 1
}
}
}
]
}
}
}
}
}

Is this possible? If so, how? 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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/154c83d7-17cc-490f-a64b-b5e6f7a95b8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.