bennylope / elasticstack

:card_index: Configurable indexing and other extras for Haystack (with ElasticSearch biases)
BSD 2-Clause "Simplified" License
127 stars 31 forks source link

Just a commen on json fields and elasticsearch #9

Closed jamartinh closed 9 years ago

jamartinh commented 9 years ago

Hello, I came to this site finding solutions and I found it here, so I publish here a contribution that may be of interest to others useing haystack and elasticsearch.

I have in the postgres database a json field and I suffered a lot to including it into elasticsearch trough haystack. The char field simply put it as a text in elastic search and ignores all the structure of the json.

If you simply declare the json field as a SearchField (the base class of all others) then haystack passes it as is to elastic search and elastic search beautifully creates a sub structure for the json field with all its properties !!! This was a nice discovery and solved a super problem I had.

Hope this be also useful for others. Cheers, Jose