How to create custom categories for text files indexed in Elasticsearch using the attachment plugin?


(Sagar Singh) #1

I have my mappings as such

{
"attachment": {
    "properties": {
        "file": {
            "type": "attachment",
            "fields": {
                "title": {
                    "store": "yes"
                },
                "author": {
                    "store": "yes"
                },
                "date": {
                    "store": "yes"
                },
                "keywords": {
                    "store": "yes"
                },
                "content_type": {
                    "store": "yes"
                },
                "file": {
                    "term_vector": "with_positions_offsets",
                    "store": "yes",
                    "index": "analyzed"
                    }
               }
            }
        }
    }
}

I want to be able to add custom categories to each file, for example if the
file is an html file then i want to read the meta tag inside and add those
categories.

If there is a better approach please let me know so as well, I am just
trying to get my feet wet with Elasticsearch and just working with the
attachment plugin for the first time.

also created a SO question on
it: http://stackoverflow.com/questions/21711216/how-to-create-custom-categories-for-text-files-indexed-in-elasticsearch-using-th

--
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/a7ce1436-bb86-40d2-a5ec-82a4d7fada75%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Binh Ly) #2

You can simply add more fields on the same level as file. For example:

"mappings": {
"doc": {
"properties" : {
"file" : {
"type" : "attachment",
"fields": {
"file": { "store": "yes" }
}
},
"meta1": {
"type": "string",
"store": "yes"
}
}
}
}

And then when you index, just specify a value for the "meta1" field in
addition to your "file" field.

--
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/d53e93b6-c595-43a8-8829-a2f3b68014d1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Binh Ly) #3

Ooops, forgot to mention "store": "yes" is optional. You don't have to
store anything if you don't need stored metadata fields.

On Tuesday, February 11, 2014 3:57:52 PM UTC-5, Binh Ly wrote:

You can simply add more fields on the same level as file. For example:

"mappings": {
"doc": {
"properties" : {
"file" : {
"type" : "attachment",
"fields": {
"file": { "store": "yes" }
}
},
"meta1": {
"type": "string",
"store": "yes"
}
}
}
}

And then when you index, just specify a value for the "meta1" field in
addition to your "file" field.

--
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/e6729c4d-14c6-4dbd-bd0a-8d96c3c97019%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Sagar Singh) #4

Thanks, I guess i should be asking how would i set those meta data during
indexing, is there a feature that ES can perform for me. i saw a way to
have custom analyzers and was trying those out to see if i can use that to
set the meta for me if there is something in that document.

On Tuesday, February 11, 2014 4:00:02 PM UTC-5, Binh Ly wrote:

Ooops, forgot to mention "store": "yes" is optional. You don't have to
store anything if you don't need stored metadata fields.

On Tuesday, February 11, 2014 3:57:52 PM UTC-5, Binh Ly wrote:

You can simply add more fields on the same level as file. For example:

"mappings": {
"doc": {
"properties" : {
"file" : {
"type" : "attachment",
"fields": {
"file": { "store": "yes" }
}
},
"meta1": {
"type": "string",
"store": "yes"
}
}
}
}

And then when you index, just specify a value for the "meta1" field in
addition to your "file" field.

--
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/38c360c3-b0e1-4da9-9018-ee951358386e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #5