Cannot set string type to analyzed


(Thomas) #1

Hi,

I'm trying to create a mapping for a nested document and I realize that i
cannot set the index type of a string field to analyzed:

{
"action": {
"_all": {
"enabled": false
},
"_type": {
"index": "no"
},
"_timestamp": {
"enabled": true,
"store": "yes"
},
"_routing": {
"required": true,
"path": "userId"
},
"properties": {
"userId": {
"type": "string",
"index": "not_analyzed"
},
"extra": {
"type": "nested",
"properties": {
"key": {
"type": "string",
"index": "not_analyzed"
},
"value": {

  • "type": "string",*
  • "index": "analyzed"*
  • }*
    }
    }
    }
    }
    }

The above ends up with the following result when calling for the mapping
(curl -XGET localhost:9200/my_index/action/_mapping?pretty ):

{
"action": {
"_all": {
"enabled": false
},
"_type": {
"index": "no"
},
"_timestamp": {
"enabled": true,
"store": "yes"
},
"_routing": {
"required": true,
"path": "userId"
},
"properties": {
"userId": {
"type" : "string",
"index" : "not_analyzed",
"omit_norms" : true,
"index_options" : "docs"
},
"extra": {
"type": "nested",
"properties": {
"key": {
"type" : "string",
"index" : "not_analyzed",
"omit_norms" : true,
"index_options" : "docs"
},
"value": {

  • "type": "string"*
  • }*
    }
    }
    }
    }
    }

Should it display index type as analyzed? furthermore I cannot search based
on this field? Should I search by defining the analyzer?

ES version 0.90.7 but i noticed this since version 0.90.2, probably I'm
doing something wrong here.

Looking forward for your reply
Thank you

--
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/01ec164d-bb31-4e5b-87d2-1a9abadb0b69%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(David Pilato) #2

Hi Thomas,

I guess it could be because "index":"analyzed" is a default value so basically you don't have to set it???

About your search concern, a curl recreation would help a lot to understand what you are actually doing.
Could you gist it?

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr

Le 17 décembre 2013 at 16:11:03, Thomas (thomas.bolis@gmail.com) a écrit:

Hi,

I'm trying to create a mapping for a nested document and I realize that i cannot set the index type of a string field to analyzed:

{
"action": {
"_all": {
"enabled": false
},
"_type": {
"index": "no"
},
"_timestamp": {
"enabled": true,
"store": "yes"
},
"_routing": {
"required": true,
"path": "userId"
},
"properties": {
"userId": {
"type": "string",
"index": "not_analyzed"
},
"extra": {
"type": "nested",
"properties": {
"key": {
"type": "string",
"index": "not_analyzed"
},
"value": {
"type": "string",
"index": "analyzed"
}
}
}
}
}
}

The above ends up with the following result when calling for the mapping (curl -XGET localhost:9200/my_index/action/_mapping?pretty ):

{
"action": {
"_all": {
"enabled": false
},
"_type": {
"index": "no"
},
"_timestamp": {
"enabled": true,
"store": "yes"
},
"_routing": {
"required": true,
"path": "userId"
},
"properties": {
"userId": {
"type" : "string",
"index" : "not_analyzed",
"omit_norms" : true,
"index_options" : "docs"
},
"extra": {
"type": "nested",
"properties": {
"key": {
"type" : "string",
"index" : "not_analyzed",
"omit_norms" : true,
"index_options" : "docs" },
"value": {
"type": "string"
}
}
}
}
}
}

Should it display index type as analyzed? furthermore I cannot search based on this field? Should I search by defining the analyzer?

ES version 0.90.7 but i noticed this since version 0.90.2, probably I'm doing something wrong here.

Looking forward for your reply
Thank you

--
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/01ec164d-bb31-4e5b-87d2-1a9abadb0b69%40googlegroups.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.52b06c0e.3dc240fb.6956%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/groups/opt_out.


(Thomas) #3

Thanks for your reply

Here is an example:

{
"query":{
"filtered":{
"query":{"term":{"userId":"testUser1"}},
"filter":{
"nested":{
"path":"extra",
"query":{
"filtered":{
"query":{"match_all":{}},
"filter":{
"bool":{
"must":[
{"term":{"key" : "city"}},
{"term":{"value" : "Stockholm"}}
]
}
}
}
}
}
}
}
},
"size":0
}

I have inserted data with key city and value Stockholm in my scenario, the
thing is that if I change the mapping to not_analyzed and run the same
scenario i get back data whereas if I set index to analyzed or not set it
at all (default value) then I do not get back results which leads me to the
conclusion that somehow analyzed is not accepted when setting mapping

Thomas

On Tuesday, December 17, 2013 5:10:58 PM UTC+2, Thomas wrote:

Hi,

I'm trying to create a mapping for a nested document and I realize that i
cannot set the index type of a string field to analyzed:

{
"action": {
"_all": {
"enabled": false
},
"_type": {
"index": "no"
},
"_timestamp": {
"enabled": true,
"store": "yes"
},
"_routing": {
"required": true,
"path": "userId"
},
"properties": {
"userId": {
"type": "string",
"index": "not_analyzed"
},
"extra": {
"type": "nested",
"properties": {
"key": {
"type": "string",
"index": "not_analyzed"
},
"value": {

  • "type": "string",*
  • "index": "analyzed"*
  • }*
    }
    }
    }
    }
    }

The above ends up with the following result when calling for the mapping
(curl -XGET localhost:9200/my_index/action/_mapping?pretty ):

{
"action": {
"_all": {
"enabled": false
},
"_type": {
"index": "no"
},
"_timestamp": {
"enabled": true,
"store": "yes"
},
"_routing": {
"required": true,
"path": "userId"
},
"properties": {
"userId": {
"type" : "string",
"index" : "not_analyzed",
"omit_norms" : true,
"index_options" : "docs"
},
"extra": {
"type": "nested",
"properties": {
"key": {
"type" : "string",
"index" :
"not_analyzed",
"omit_norms" : true,
"index_options" : "docs"
},
"value": {

  • "type": "string"*
  • }*
    }
    }
    }
    }
    }

Should it display index type as analyzed? furthermore I cannot search
based on this field? Should I search by defining the analyzer?

ES version 0.90.7 but i noticed this since version 0.90.2, probably I'm
doing something wrong here.

Looking forward for your reply
Thank you

--
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/b31fd783-2477-4011-8f59-6c7651b0437e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(David Pilato) #4

I think it's the intended result.

When not_analyzed, Stockholm is indexed as Stockholm
When analyzed, Stockholm is indexed as stockholm

TermFilter is not analyzed. So searching for Stockholm will work with not_analyzed and won't with analyzed.

If I'm wrong, could it be possible to GIST a full curl recreation as explained here, please: http://www.elasticsearch.org/help/
It will help a lot to understand what you are doing.

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr

Le 17 décembre 2013 at 16:37:38, Thomas (thomas.bolis@gmail.com) a écrit:

Thanks for your reply

Here is an example:

{
"query":{
"filtered":{
"query":{"term":{"userId":"testUser1"}},
"filter":{
"nested":{
"path":"extra",
"query":{
"filtered":{
"query":{"match_all":{}},
"filter":{
"bool":{
"must":[
{"term":{"key" : "city"}},
{"term":{"value" : "Stockholm"}}
]
}
}
}
}
}
}
}
},
"size":0
}

I have inserted data with key city and value Stockholm in my scenario, the thing is that if I change the mapping to not_analyzed and run the same scenario i get back data whereas if I set index to analyzed or not set it at all (default value) then I do not get back results which leads me to the conclusion that somehow analyzed is not accepted when setting mapping

Thomas

On Tuesday, December 17, 2013 5:10:58 PM UTC+2, Thomas wrote:
Hi,

I'm trying to create a mapping for a nested document and I realize that i cannot set the index type of a string field to analyzed:

{
"action": {
"_all": {
"enabled": false
},
"_type": {
"index": "no"
},
"_timestamp": {
"enabled": true,
"store": "yes"
},
"_routing": {
"required": true,
"path": "userId"
},
"properties": {
"userId": {
"type": "string",
"index": "not_analyzed"
},
"extra": {
"type": "nested",
"properties": {
"key": {
"type": "string",
"index": "not_analyzed"
},
"value": {
"type": "string",
"index": "analyzed"
}
}
}
}
}
}

The above ends up with the following result when calling for the mapping (curl -XGET localhost:9200/my_index/action/_mapping?pretty ):

{
"action": {
"_all": {
"enabled": false
},
"_type": {
"index": "no"
},
"_timestamp": {
"enabled": true,
"store": "yes"
},
"_routing": {
"required": true,
"path": "userId"
},
"properties": {
"userId": {
"type" : "string",
"index" : "not_analyzed",
"omit_norms" : true,
"index_options" : "docs"
},
"extra": {
"type": "nested",
"properties": {
"key": {
"type" : "string",
"index" : "not_analyzed",
"omit_norms" : true,
"index_options" : "docs" },
"value": {
"type": "string"
}
}
}
}
}
}

Should it display index type as analyzed? furthermore I cannot search based on this field? Should I search by defining the analyzer?

ES version 0.90.7 but i noticed this since version 0.90.2, probably I'm doing something wrong here.

Looking forward for your reply
Thank you

--
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/b31fd783-2477-4011-8f59-6c7651b0437e%40googlegroups.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.52b0713b.47398c89.6956%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/groups/opt_out.


(Thomas) #5

You are 100% correct I changed it to lowercase and got back the desired
result

Thanks a lot David

Thomas

On Tuesday, December 17, 2013 5:10:58 PM UTC+2, Thomas wrote:

Hi,

I'm trying to create a mapping for a nested document and I realize that i
cannot set the index type of a string field to analyzed:

{
"action": {
"_all": {
"enabled": false
},
"_type": {
"index": "no"
},
"_timestamp": {
"enabled": true,
"store": "yes"
},
"_routing": {
"required": true,
"path": "userId"
},
"properties": {
"userId": {
"type": "string",
"index": "not_analyzed"
},
"extra": {
"type": "nested",
"properties": {
"key": {
"type": "string",
"index": "not_analyzed"
},
"value": {

  • "type": "string",*
  • "index": "analyzed"*
  • }*
    }
    }
    }
    }
    }

The above ends up with the following result when calling for the mapping
(curl -XGET localhost:9200/my_index/action/_mapping?pretty ):

{
"action": {
"_all": {
"enabled": false
},
"_type": {
"index": "no"
},
"_timestamp": {
"enabled": true,
"store": "yes"
},
"_routing": {
"required": true,
"path": "userId"
},
"properties": {
"userId": {
"type" : "string",
"index" : "not_analyzed",
"omit_norms" : true,
"index_options" : "docs"
},
"extra": {
"type": "nested",
"properties": {
"key": {
"type" : "string",
"index" :
"not_analyzed",
"omit_norms" : true,
"index_options" : "docs"
},
"value": {

  • "type": "string"*
  • }*
    }
    }
    }
    }
    }

Should it display index type as analyzed? furthermore I cannot search
based on this field? Should I search by defining the analyzer?

ES version 0.90.7 but i noticed this since version 0.90.2, probably I'm
doing something wrong here.

Looking forward for your reply
Thank you

--
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/804070ec-5601-45b5-83e4-840d72f348af%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #6