Query on _content_type?


(nurikabe) #1

I think I'm overlooking something obvious here. If I have data indexed
with the mapper-attachment like so:

{

  • _index: index
  • _type: type
  • _id: s8SSO7frShGcVH8P8rSaaw
  • _version: 1
  • _score: 1
  • _source: {
    • id: { ... }
    • user: { ... }
    • date_created: 1321286179
    • date_updated: 1321286179
    • visibility: visible
    • title: Linguiste
    • file: {
      • _content_type: application/pdf
      • content:JVBERi0xLjUNCiW1tbW...
        }
        }

}

how can I query on content type? I thought I would be able to do something
like:

{
"query": {
"term": {
"file._content_type": "pdf"
}
}
}

but no dice. Where am I going wrong?

Thanks!


(Shay Banon) #2

Its called content_type, or in your case, file.content_type should work. The _content_type option in the json is a hint to the parser (which might be able to derive it automatically if not provided), and then its indexed under content_type.

On Monday, February 13, 2012 at 8:41 PM, nurikabe wrote:

I think I'm overlooking something obvious here. If I have data indexed with the mapper-attachment like so:

{
_index: index
_type: type
_id: s8SSO7frShGcVH8P8rSaaw
_version: 1
_score: 1
_source: {
id: { ... }
user: { ... }
date_created: 1321286179
date_updated: 1321286179
visibility: visible
title: Linguiste
file: {
_content_type: application/pdf
content:JVBERi0xLjUNCiW1tbW...

}

}

}

how can I query on content type? I thought I would be able to do something like:

{
"query": {
"term": {
"file._content_type": "pdf"
}
}
}

but no dice. Where am I going wrong?

Thanks!


(system) #3