A
A
alex_cube_eng2018-03-23 23:36:40
PostgreSQL
alex_cube_eng, 2018-03-23 23:36:40

Is it possible to search by an occurrence in a Django JSONField?

Good day! I work with semi-structured data. I use the classic EAV model. But there is no limit to perfection. Found time to try replacing EAV with jsonb in postgresql. I stumbled on the fact that I can’t figure out how to implement a search for an occurrence in a string. Is it possible? If so, how? A Django or pure SQL solution will do. To make it clearer, an example: there is a model

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

json is stored in the data field (2 rows in the database table):
{"name": "Michael", "friend_name": "Sara"}
{"name": "Miranda", "friend_name": "Richard"}

The search implies that when you enter "ar" it will return both strings ("ar" in "Sara", "ar" in "Miranda"), "cha" - again two strings ("cha" in "Michael", "ar" in "Richard"), "ir" - only one ("ir" in "Miranda"), "asdq" - none. Is it possible to implement this in Django? Is it possible to implement using SQL?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2018-03-23
@alex_cube_eng

Any _normal_ solution will put shinxsearch and shamanize Clumsy
- we take the whole dict and glue it into a string with spaces and look for it like

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question