Hi,
Did you try
SomeModel.objects.filter(data__name__contains="ar")
If you want to union the results from both fields you can use a Q object:
https://docs.djangoproject.com/en/2.0/topics/db/queries/#complex-lookups-with-q-objects
And that would look something like:
complex_query = Q(data__name__contains="ar") |
Q(data__friend_name__contains="ar)
SomeModel.objects.filter( complex_query )
Hope that helps.
Cheers!
On 3/23/2018 1:20 PM, Алексей Кузуб wrote:
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+unsubscr...@googlegroups.com
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto: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
<https://groups.google.com/d/msgid/django-users/a3bb18e9-c513-493b-a3a8-5f8da1a40b81%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
This message has been scanned for viruses and dangerous content by
*E.F.A. Project* <http://www.efa-project.org>, and is believed to be
clean.
Click here to report this message as spam.
<http://lsefa1.linear-systems.com/cgi-bin/learn-msg.cgi?id=7972010235E.AA8A6&token=ae2ba832900b01fd5984e6a2eb681617>
--
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+unsubscr...@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/16ad14a9-da25-f494-114a-1fd115ceb04d%40linear-systems.com.
For more options, visit https://groups.google.com/d/optout.