Removing docs from search results

Hi everyone,

I am having the next issue: I want to remove some docs from the results
based in conditions. I think this is the behavior that 'filters' have. The
problem is that couldn't get with the correct solution.

Example:

If I have an index with shops like :

{
"Shop": {
"name": 'Bakery My Bread'
}
},
{
"Shop": {
"name": 'Butcher Jason'
}
},
{
"Shop": {
"name": 'Sex Shop Toys'
}
},
{
"Shop": {
"name": 'Video Shop DVD'
}
},

What I did was to add 'sex' to the stopwords file so if someone search
that word, it is discarded. This works fine at search time for that word
because since it is a single token, none results are retrieved. The problem
occurs when someone search something like 'shop', and, in this case, 2
results are retrieved, and one of them is 'Sex Shop Toys', something I
don't want to retrieve.

Should I use some filter specifically? I tried with bool filter, regexp and
not filter but those undesirable results still being brought.

Thanks in advance

--
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/3218ec76-7082-4cd1-a44b-11b450f86669%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

You have to use a technique known as anti-phrasing. "not" filters work well.

In your case of a "shop" query, something like

{
"query" : {
"filtered" : {
"query" : {
"simple_query_string" : {
"query" : "shop",
"default_operator": "and"
}
},
"filter" : {
"not" : {
"_cache": true,
"filter" : {
"query": {
"match" : {
"_all" : "sex"
}
}
}
}
}
}
}
}

Other example with query_string:

Jörg

On Mon, Sep 29, 2014 at 8:04 PM, @mromagnoli marce.romagnoli@gmail.com
wrote:

Hi everyone,

I am having the next issue: I want to remove some docs from the results
based in conditions. I think this is the behavior that 'filters' have. The
problem is that couldn't get with the correct solution.

Example:

If I have an index with shops like :

{
"Shop": {
"name": 'Bakery My Bread'
}
},
{
"Shop": {
"name": 'Butcher Jason'
}
},
{
"Shop": {
"name": 'Sex Shop Toys'
}
},
{
"Shop": {
"name": 'Video Shop DVD'
}
},

What I did was to add 'sex' to the stopwords file so if someone search
that word, it is discarded. This works fine at search time for that word
because since it is a single token, none results are retrieved. The problem
occurs when someone search something like 'shop', and, in this case, 2
results are retrieved, and one of them is 'Sex Shop Toys', something I
don't want to retrieve.

Should I use some filter specifically? I tried with bool filter, regexp
and not filter but those undesirable results still being brought.

Thanks in advance

--
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/3218ec76-7082-4cd1-a44b-11b450f86669%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/3218ec76-7082-4cd1-a44b-11b450f86669%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 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/CAKdsXoHkOd--PExgEcZ5qH-fgXUBBD9h4EL_HS%3D-CZJJxqAQ7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Jörg, worked perfectly with my problem!!!

Thank you very much for your response and your time.

Marcelo

On Monday, September 29, 2014 3:33:49 PM UTC-3, Jörg Prante wrote:

You have to use a technique known as anti-phrasing. "not" filters work
well.

In your case of a "shop" query, something like

{
"query" : {
"filtered" : {
"query" : {
"simple_query_string" : {
"query" : "shop",
"default_operator": "and"
}
},
"filter" : {
"not" : {
"_cache": true,
"filter" : {
"query": {
"match" : {
"_all" : "sex"
}
}
}
}
}
}
}
}

Other example with query_string:

https://gist.github.com/jprante/6816555

Jörg

On Mon, Sep 29, 2014 at 8:04 PM, @mromagnoli <marce.r...@gmail.com
<javascript:>> wrote:

Hi everyone,

I am having the next issue: I want to remove some docs from the results
based in conditions. I think this is the behavior that 'filters' have. The
problem is that couldn't get with the correct solution.

Example:

If I have an index with shops like :

{
"Shop": {
"name": 'Bakery My Bread'
}
},
{
"Shop": {
"name": 'Butcher Jason'
}
},
{
"Shop": {
"name": 'Sex Shop Toys'
}
},
{
"Shop": {
"name": 'Video Shop DVD'
}
},

What I did was to add 'sex' to the stopwords file so if someone search
that word, it is discarded. This works fine at search time for that word
because since it is a single token, none results are retrieved. The problem
occurs when someone search something like 'shop', and, in this case, 2
results are retrieved, and one of them is 'Sex Shop Toys', something I
don't want to retrieve.

Should I use some filter specifically? I tried with bool filter, regexp
and not filter but those undesirable results still being brought.

Thanks in advance

--
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 elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/3218ec76-7082-4cd1-a44b-11b450f86669%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/3218ec76-7082-4cd1-a44b-11b450f86669%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 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/915a89b2-968a-45a2-939b-d59375f9243d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.