String not_analyzed with whitespaces


(didier.baquier) #1

Hey folks,

I spent my afternoon trying to have a field not analyzed with whitespaces.

I want to index a payment status : Not Paid / Paid, that field must not be
tokenized.

So, here is my mapping (really basic):
"label" -> Map("type" -> "string", "index" -> "not_analyzed", "search" ->
"not_analyzed", "store" -> "yes")

The following queries work fine, I got my 2 entries:
{
"bool" : {
"must" : {
"dis_max" : {
"tie_breaker" : 0.7,
"queries" : [ {
"field" : {
"statuses.payment.label" : "Paid"
}
}, {
"field" : {
"user_code_analysis" : {
"query" : "Paid",
"boost" : 1.2
}
}
} ]
}
}
}
}

If I want to do the exact same thing with "Not Paid" instead of Paid :
{
"bool" : {
"must" : {
"dis_max" : {
"tie_breaker" : 0.7,
"queries" : [ {
"field" : {
"statuses.payment.label" : "Not Paid"
}
}, {
"field" : {
"user_code_analysis" : {
"query" : "Not Paid",
"boost" : 1.2
}
}
} ]
}
}
}
}

The query returns 0 result (normally 1 entry), if I indexed "NotPaid" as a
status instead of "Not Paid", I've got my entry.

So my issue comes from the whitespace. Am I missing something? Do I need to
analyze the field?

PS: my mapping is applied, if I execute _mapping I can see :
...
"payment": {
"properties": {
....
"label": {
"type": "string",
"index": "not_analyzed",
"store": "yes"
}
}
},

thanks for your help

--
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.


(Jun Ohtani) #2

Hi,

Field Query is Query String Query .
"query" is parsed by query parser.

You try to use Term Query instead of Field Query.


Jun Ohtani
johtani@gmail.com
twitter : http://twitter.com/johtani

On 2013/09/25, at 11:26, didier.baquier@gmail.com wrote:

Hey folks,

I spent my afternoon trying to have a field not analyzed with whitespaces.

I want to index a payment status : Not Paid / Paid, that field must not be tokenized.

So, here is my mapping (really basic):
"label" -> Map("type" -> "string", "index" -> "not_analyzed", "search" -> "not_analyzed", "store" -> "yes")

The following queries work fine, I got my 2 entries:
{
"bool" : {
"must" : {
"dis_max" : {
"tie_breaker" : 0.7,
"queries" : [ {
"field" : {
"statuses.payment.label" : "Paid"
}
}, {
"field" : {
"user_code_analysis" : {
"query" : "Paid",
"boost" : 1.2
}
}
} ]
}
}
}
}

If I want to do the exact same thing with "Not Paid" instead of Paid :
{
"bool" : {
"must" : {
"dis_max" : {
"tie_breaker" : 0.7,
"queries" : [ {
"field" : {
"statuses.payment.label" : "Not Paid"
}
}, {
"field" : {
"user_code_analysis" : {
"query" : "Not Paid",
"boost" : 1.2
}
}
} ]
}
}
}
}

The query returns 0 result (normally 1 entry), if I indexed "NotPaid" as a status instead of "Not Paid", I've got my entry.

So my issue comes from the whitespace. Am I missing something? Do I need to analyze the field?

PS: my mapping is applied, if I execute _mapping I can see :
...
"payment": {
"properties": {
....
"label": {
"type": "string",
"index": "not_analyzed",
"store": "yes"
}
}
},

thanks for your help

--
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.


(system) #3