Filter syntax

Hi,

I am new to elasticsearch and I am struggling with a simple syntax.

I created 4 elements like this:
'{"numvente":1,"numlignvente":1,"produit":2866,"prixunitaire":22.32,"qte":20,"vendeur":"D","numtel":"0653243949","rayon":"ELECTRO","magasin":"IDF","region":"1"}
'
'{"numvente":1,"numlignvente":2,"produit":4358,"prixunitaire":3.39,"qte":2,"vendeur":"D","numtel":"0653266649","rayon":"ELECTRO","magasin":"IDF","region":"1"}
'
'{"numvente":1,"numlignvente":3,"produit":2538,"prixunitaire":20.253,"qte":1,"vendeur":"D","numtel":"069988203","rayon":"ELECTRO","magasin":"IDF","region":"1"}
'
'{"numvente":2,"numlignvente":1,"produit":2230,"prixunitaire":324.99,"qte":3,"vendeur":"D","numtel":"0123456577","rayon":"ELECTRO","magasin":"IDF","region":"1"}
'

My goal is to be able to search through several elements of my index. In
this case, I would be able to find any products or phone numbers containing
the "53" string.

Could you help me correcting this?

{

"query": {
"filtered": {
"query": {

     "term": "53"
   
 },
 "filter": {
   "match_all": {}
 }

}
}
}

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Just one more thing, I set a mapping using nGram tokenizer to be able to
perform a search inside strings.
Please find it attached.

Thanks!

Le mercredi 24 juillet 2013 16:38:09 UTC+2, aYm a écrit :

Hi,

I am new to elasticsearch and I am struggling with a simple syntax.

I created 4 elements like this:
'{"numvente":1,"numlignvente":1,"produit":2866,"prixunitaire":22.32,"qte":20,"vendeur":"D","numtel":"0653243949","rayon":"ELECTRO","magasin":"IDF","region":"1"}
'
'{"numvente":1,"numlignvente":2,"produit":4358,"prixunitaire":3.39,"qte":2,"vendeur":"D","numtel":"0653266649","rayon":"ELECTRO","magasin":"IDF","region":"1"}
'
'{"numvente":1,"numlignvente":3,"produit":2538,"prixunitaire":20.253,"qte":1,"vendeur":"D","numtel":"069988203","rayon":"ELECTRO","magasin":"IDF","region":"1"}
'
'{"numvente":2,"numlignvente":1,"produit":2230,"prixunitaire":324.99,"qte":3,"vendeur":"D","numtel":"0123456577","rayon":"ELECTRO","magasin":"IDF","region":"1"}
'

My goal is to be able to search through several elements of my index. In
this case, I would be able to find any products or phone numbers containing
the "53" string.

Could you help me correcting this?

{

"query": {
"filtered": {
"query": {

     "term": "53"
   
 },
 "filter": {
   "match_all": {}
 }

}
}
}

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi,

Your query is off in a few places. First of all, a term query needs both a
field and value. For example:

{
"term" : { "numvente" : "53" }
}

You can also use the _all field if it is enabled. However, you probably do
not want the term query, but a query_string query (or perhaps match):
http://www.elasticsearch.org/guide/reference/query-dsl/query-string-query/

You can omit the field name, and it will default to the _all field.

Second, your query and filters are reversed. Filters are almost like
queries, except that the do not contribute to the scoring of a document and
they can be cached. A standard practice is to execute a match_all query and
then filter out documents. Each document will have the same score of 1.0.

{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"term": { "_all": "53" }
}
}
}
}

Try running some simple queries first before diving into ngrams.

Cheers,

Ivan

On Wed, Jul 24, 2013 at 7:44 AM, aYm aymeric.martin@ysance.com wrote:

Just one more thing, I set a mapping using nGram tokenizer to be able to
perform a search inside strings.
Please find it attached.

Thanks!

Le mercredi 24 juillet 2013 16:38:09 UTC+2, aYm a écrit :

Hi,

I am new to elasticsearch and I am struggling with a simple syntax.

I created 4 elements like this:
'{"numvente":1,"numlignvente":1,"produit":2866,"
prixunitaire":22.32,"qte":20,"vendeur":"D","numtel":"
0653243949","rayon":"ELECTRO","magasin":"IDF","region":"1"} '
'{"numvente":1,"numlignvente":2,"produit":4358,"
prixunitaire":3.39,"qte":2,"vendeur":"D","numtel":"
0653266649","rayon":"ELECTRO",
"magasin":"IDF","region":"1"} '
'{"numvente":1,"numlignvente":3,"produit":2538,"
prixunitaire":20.253,"qte":1,"vendeur":"D","numtel":"
069988203","rayon":"ELECTRO","magasin":"IDF","region":"1"} '
'{"numvente":2,"numlignvente":1,"produit":2230,"
prixunitaire":324.99,"qte":3,"vendeur":"D","numtel":"
0123456577","rayon":"ELECTRO",
"magasin":"IDF","region":"1"} '

My goal is to be able to search through several elements of my index. In
this case, I would be able to find any products or phone numbers containing
the "53" string.

Could you help me correcting this?

{

"query": {
"filtered": {
"query": {

     "term": "53"

 },
 "filter": {
   "match_all": {}
 }

}
}
}

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks Ivan! I'll try this.

Le jeudi 25 juillet 2013 01:09:52 UTC+2, Ivan Brusic a écrit :

Hi,

Your query is off in a few places. First of all, a term query needs both a
field and value. For example:

{
"term" : { "numvente" : "53" }
}

You can also use the _all field if it is enabled. However, you probably do
not want the term query, but a query_string query (or perhaps match):
http://www.elasticsearch.org/guide/reference/query-dsl/query-string-query/

You can omit the field name, and it will default to the _all field.

Second, your query and filters are reversed. Filters are almost like
queries, except that the do not contribute to the scoring of a document and
they can be cached. A standard practice is to execute a match_all query and
then filter out documents. Each document will have the same score of 1.0.

{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"term": { "_all": "53" }
}
}
}
}

Try running some simple queries first before diving into ngrams.

Cheers,

Ivan

On Wed, Jul 24, 2013 at 7:44 AM, aYm <aymeric...@ysance.com <javascript:>>wrote:

Just one more thing, I set a mapping using nGram tokenizer to be able to
perform a search inside strings.
Please find it attached.

Thanks!

Le mercredi 24 juillet 2013 16:38:09 UTC+2, aYm a écrit :

Hi,

I am new to elasticsearch and I am struggling with a simple syntax.

I created 4 elements like this:
'{"numvente":1,"numlignvente":1,"produit":2866,"
prixunitaire":22.32,"qte":20,"vendeur":"D","numtel":"
0653243949","rayon":"ELECTRO","magasin":"IDF","region":"1"} '
'{"numvente":1,"numlignvente":2,"produit":4358,"
prixunitaire":3.39,"qte":2,"vendeur":"D","numtel":"
0653266649","rayon":"ELECTRO",
"magasin":"IDF","region":"1"} '
'{"numvente":1,"numlignvente":3,"produit":2538,"
prixunitaire":20.253,"qte":1,"vendeur":"D","numtel":"
069988203","rayon":"ELECTRO","magasin":"IDF","region":"1"} '
'{"numvente":2,"numlignvente":1,"produit":2230,"
prixunitaire":324.99,"qte":3,"vendeur":"D","numtel":"
0123456577","rayon":"ELECTRO",
"magasin":"IDF","region":"1"} '

My goal is to be able to search through several elements of my index. In
this case, I would be able to find any products or phone numbers containing
the "53" string.

Could you help me correcting this?

{

"query": {
"filtered": {
"query": {

     "term": "53"
   
 },
 "filter": {
   "match_all": {}
 }

}
}
}

--
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:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.