Friday, March 23, 2018

Search by entering to value in JSONField PostgreSQL

Hi! I work with poorly structured data. I use EAV. But I want to replace EAV with jsonb in postgresql. I need to do a search by entering to value in json.values(). Is it possible? Is there some decision on Django or SQL?For example, there is the model

class SomeModel(models.Model):      data = JSONField()  

That jsons stored in rows in data field:

{"name": "Michael", "friend_name": "Sara"}  {"name": "Miranda", "friend_name": "Richard"}  

If I type "ar" in search input I want to get both rows("ar" in "Sara""ar" in "Miranda"), "cha" - both rows( "cha" in "Michael""ar" in "Richard"), "ir" - only one ("ir" in "Miranda"), "asdq" - nothing. Is it possible with Django? Is it possible with SQL? Thank you and sorry for my English.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a3bb18e9-c513-493b-a3a8-5f8da1a40b81%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment