| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|----------------------------------------------------------------------------------------------------------------------------|
| 1 | SIMPLE | big_table | 2018_9_1 | ALL | NULL | NULL | NULL | NULL | 120477 | 0.01 | Using where |
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1 | SIMPLE | big_table | здесь список всех партиций | range | date_time_index | date_time_index | 9 | NULL | 40 | 10.01 | Using index conditions |
[
{"id": 1, "body": "Aki doing his homework about japanese robot in library."},
{"id": 3, "body": "Japanese robot Aki doing a lot of tasks."},
]
[
{"id": 1, "body": "Aki his homework about japanese robot in."},
{"id": 3, "body": "Japanese robot Aki a lot of tasks."},
]
class ArticleFilterView(APIView):
@staticmethod
def post(request):
article_filter = Q()
search = list(request.data.values())[0] # Первый массив со строками. Например: ["Aki", "robot"]
for item in search:
article_filter &= Q(body__icontains=item)
queryset = Article.objects.filter(article_filter)
if queryset.exists():
serializer = ArticleSerializer(queryset, many=True)
print(serializer.data)
return Response(data=serializer.data)
return Response({"message": "Данные не найдены"})
{"detail":"Method \"POST\" not allowed."}
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
),
'DEFAULT_PARSER_CLASSES': (
'rest_framework.parsers.JSONParser',
),
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.AllowAny',
],
}
curl -X POST -H "Content-Type: application/json" -d
'[{"first": ["Aki", "robot"], "second": ["doing", "library"]}]'
http://localhost:8000/api/article/filter/
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated'
),
{"detail":"Authentication credentials were not provided."}
DISTINCT ON fields is not supported by this database backend.
К слову встретил на форуме обсуждение по этому поводу.sql_result = SecuritiesParams.objects.raw("""
здесь первый запрос
""")
for p in sql_result:
print(p)
DatabaseError: ORA-00936: missing expression
2018-09-15
по2018-10-15
. По сути тоже месячный период считай. Даже если я добавлю индексирование на поля YEAR, MONTH, DAY, как правильно составить запрос по этим полям?