How to use path_hierarchy tokenizer

Hello,

I'm setting up our first ElasticSearch server. It's going well so far,
except I need to figure out how to index our hierarchical categories. I've
found the path_tokenizer for that purpose, and I'm attempting to make it
work. I've been through the docs and other sources, but I'm lost -- there
seem to be multiple ways to do this.

My understanding is that I should be able to create my index with mappings
as follows. If it makes any difference, the categories field is an array of
values.

Am I on the right track? I'm indexing documents but have been unable to
make any path query work so far.

{
"index": {},
"settings": {
"analysis": {
"analyzer": {
"category_path": {
"type": "custom",
"tokenizer": "category_path"
}
},
"tokenizer": {
"category_path": {
"type": "path_hierarchy",
"delimiter": "/"
}
}
}
},
"mappings": {
"Product": {
"properties": {
"categories": {
"type": "string",
"path": {
"type": "string",
"analyzer": "category_path"
}
}
}
}
}
}

Hi Shane!

Have you found a solution to this? I'm also experiencing problems having
the path_hierarchy tokenizer to work. I've created a mapping and I've
issued a number of _analyze request such as

_analyze?field=hierarchy&text=level0/level1/level2.../leveln - where
"hierarchy" is my, well, hierarchy property:)

The result looks exactly the way I want it, creating n-number of terms.
However when I try to "filter" my resultset based on that property it seems
like the various terms are not indexed...

If you've found a solution to this I'd be very happy if you would share it
with me:)

Cheers

On Tuesday, July 24, 2012 12:56:16 AM UTC+2, shane wrote:

Hello,

I'm setting up our first Elasticsearch server. It's going well so far,
except I need to figure out how to index our hierarchical categories. I've
found the path_tokenizer for that purpose, and I'm attempting to make it
work. I've been through the docs and other sources, but I'm lost -- there
seem to be multiple ways to do this.

My understanding is that I should be able to create my index with mappings
as follows. If it makes any difference, the categories field is an array of
values.

Am I on the right track? I'm indexing documents but have been unable to
make any path query work so far.

{
"index": {},
"settings": {
"analysis": {
"analyzer": {
"category_path": {
"type": "custom",
"tokenizer": "category_path"
}
},
"tokenizer": {
"category_path": {
"type": "path_hierarchy",
"delimiter": "/"
}
}
}
},
"mappings": {
"Product": {
"properties": {
"categories": {
"type": "string",
"path": {
"type": "string",
"analyzer": "category_path"
}
}
}
}
}
}

--