Dynamic doc Mapping

Hi, I'm trying to index results of a questionnaire App.

Users can create questionnaires with one or more questions where answers
can have a numeric or text response.
So, a sample document will look like:

result: {
questionnaire_id: 1,
responses: [
{question_id: 1, value: 1},
{question_id: 2, value: 'some text'}
]
}

So as each questionnaire is different, should I create a different type for
each different questionnaire? or using a nested type (for responses field)
would be a better approach?
The idea would be to query for ranges on numeric values and make a full
text search on text values.

Thanks in advice!

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Hello Gustavo,

I am no expert, but I have a couple thoughts that might get you thinking
down the right path.

  1. You could name the value fields according to their data type, allowing
    numeric data to be indexed and analyzed separately from text. ie:

result: {
questionnaire_id: 1,
responses: [
{question_id: 1, value_numeric: 1},
{question_id: 2, value_text: 'some text'}
]
}

The dynamic mapping would see the response object as having one of a list
of possible fields.

  1. You could configure your mapper to treat it all as text. If you are not
    as concerned with data type, and don't plan on doing numerical analytics on
    the data in this index, then take advantage of the configurable nature of
    the dynamic mapping to treat everything in the value field as text. See:
    http://www.elasticsearch.org/guide/reference/mapping/root-object-type/

I hope that helps,

  • Ben

--
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.
For more options, visit https://groups.google.com/groups/opt_out.