Description
hi, I love the pkg ,but encounter a problem:
env:
Django (1.11.1)
django-elasticsearch-dsl (0.4.4)
elasticsearch (6.1.1)
elasticsearch-dsl (6.1.0)
in django settings.py :
ELASTICSEARCH_DSL = {
'default': {
'hosts': '10.11.96.28:9200'
},
}
Database
https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
models.py:
from django.db import models
class News(models.Model):
id=models.IntegerField(primary_key=True)
title=models.CharField(max_length=100)
author=models.CharField(max_length=100)
releasetime=models.DateTimeField(auto_now_add=True)
content=models.TextField()
keywords=models.CharField(max_length=100)
cattegory=models.IntegerField(choices=[
(1, "Notice"),
(2, "News"),
(3, "Else"),
])
class Meta:
app_label = 'knows'
ordering = ['-releasetime']
the documents.py:
from django_elasticsearch_dsl import DocType, Index
from .models import News
Name of the Elasticsearch index
hidbanews = Index('hidba_news')
See Elasticsearch Indices API reference for available settings
hidbanews.settings(
number_of_shards=1,
number_of_replicas=2
)
@hidbanews.doc_type
class NewsDocument(DocType):
class Meta:
model = News # The model associated with this DocType
# The fields of the model you want to be indexed in Elasticsearch
fields = [
'title',
'author',
'content',
'keywords',
'cattegory',
]
when I search data from NewsDocument, why it access the sqlite3, what's wrong ,how to solve the problem?
cc=NewsDocument.search().filter('match',title='Car one2')
cc.to_queryset()
2018-03-08 16:04:50,583 [MainThread:46990246997056] [django.db.backends:91] [utils:execute] [DEBUG]- (0.000) SELECT "knows_news"."id", "knows_news"."title", "knows_news"."author", "knows_news"."releasetime", "knows_news"."content", "knows_news"."keywords", "knows_news"."cattegory" FROM "knows_news" WHERE "knows_news"."id" IN (1520488895047) ORDER BY CASE WHEN "knows_news"."id" = 1520488895047 THEN 0 ELSE NULL END ASC LIMIT 21; args=(1520488895047, 1520488895047, 0)
Traceback (most recent call last):
File "/paic/dba/home/opdba/pyenv/versions/3.6.2/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/paic/dba/home/opdba/pyenv/versions/3.6.2/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 328, in execute
return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: knows_news
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "", line 1, in
File "/app/pyenv/versions/3.6.2/lib/python3.6/site-packages/django/db/models/query.py", line 226, in repr
data = list(self[:REPR_OUTPUT_SIZE + 1])
File "/app/pyenv/versions/3.6.2/lib/python3.6/site-packages/django/db/models/query.py", line 250, in iter
self._fetch_all()
File "/app/pyenv/versions/3.6.2/lib/python3.6/site-packages/django/db/models/query.py", line 1103, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/app/pyenv/versions/3.6.2/lib/python3.6/site-packages/django/db/models/query.py", line 53, in iter
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
File "/app/pyenv/versions/3.6.2/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 886, in execute_sql
raise original_exception
File "/app/pyenv/versions/3.6.2/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 876, in execute_sql
cursor.execute(sql, params)
File "/app/pyenv/versions/3.6.2/lib/python3.6/site-packages/django/db/backends/utils.py", line 80, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/app/pyenv/versions/3.6.2/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/app/pyenv/versions/3.6.2/lib/python3.6/site-packages/django/db/utils.py", line 94, in exit
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/app/pyenv/versions/3.6.2/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/app/pyenv/versions/3.6.2/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/app/pyenv/versions/3.6.2/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 328, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: knows_news