Problem in search when use "index: not_analyzed"

Hello, i have a problem if i search for a field mapping it as "index:
not_analyed"

This is my script that create the index:

curl -XPUT 'http://localhost:9200/contenidos' -d '{
"mappings": {
"categoria": {
"_all": { "enabled": false },
"_source": { "compressed": true },
"properties": {
"name": { "type": "string", "index": "analyzed" },
"alpha": { "type": "string", "index": "not_analyzed" }
}
}
}
}'

Here the script that insert data:

curl -XPUT 'http://localhost:9200/contenidos/categoria/3371' -d '{ "name":
"Circo del Sol", "parentId": "123" }'
curl -XPUT 'http://localhost:9200/contenidos/categoria/13571' -d '{ "name":
"Circo del Sol Pepito", "parentId": "123" }'
curl -XPUT 'http://localhost:9200/contenidos/categoria/21855' -d '{ "name":
"Circo del Sol Zaragoza", "parentId": "122" }'
curl -XPUT 'http://localhost:9200/contenidos/categoria/3750' -d '{ "name":
"Circo del Sol - Corteo", "parentId": "125" }'

If i search for field "name" wthis this query all results have de same
score:

{
"explain": false,
"size": "10",
"query": {
"match": {
"name": "circo del sol"
}
}
}

But if i do the same search, but with the field "alpha", i get not results,
the query is:

{
"explain": false,
"size": "10",
"query": {
"match": {
"alpha": "circo del sol"
}
}
}

Please, if anyone has any idea how i do the search will be very gratefull.
Thanks!!

--

There is a couple of issues here. First of all, your data doesn't contain
the field "alpha". So, only the field "name" is ever getting indexed. If
you want to index the same field in two different ways, you need to map it
as multi-fieldhttp://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html.
The second issue is that when a field mapped as "not_analyzed" it's indexed
as is. It means that "Circo del Sol" is going to be found only by
searching for "Circo del Sol". The match queries for "circo del sol" or
" "Circo del" are not going to work.

On Tuesday, November 6, 2012 6:50:08 AM UTC-5, Fernando Garrido wrote:

Hello, i have a problem if i search for a field mapping it as "index:
not_analyed"

This is my script that create the index:

curl -XPUT 'http://localhost:9200/contenidos' -d '{
"mappings": {
"categoria": {
"_all": { "enabled": false },
"_source": { "compressed": true },
"properties": {
"name": { "type": "string", "index": "analyzed" },
"alpha": { "type": "string", "index": "not_analyzed" }
}
}
}
}'

Here the script that insert data:

curl -XPUT 'http://localhost:9200/contenidos/categoria/3371' -d '{
"name": "Circo del Sol", "parentId": "123" }'
curl -XPUT 'http://localhost:9200/contenidos/categoria/13571' -d '{
"name": "Circo del Sol Pepito", "parentId": "123" }'
curl -XPUT 'http://localhost:9200/contenidos/categoria/21855' -d '{
"name": "Circo del Sol Zaragoza", "parentId": "122" }'
curl -XPUT 'http://localhost:9200/contenidos/categoria/3750' -d '{
"name": "Circo del Sol - Corteo", "parentId": "125" }'

If i search for field "name" wthis this query all results have de same
score:

{
"explain": false,
"size": "10",
"query": {
"match": {
"name": "circo del sol"
}
}
}

But if i do the same search, but with the field "alpha", i get not
results, the query is:

{
"explain": false,
"size": "10",
"query": {
"match": {
"alpha": "circo del sol"
}
}
}

Please, if anyone has any idea how i do the search will be very gratefull.
Thanks!!

--