django elasticsearch giving empty records while the database has records
up vote
1
down vote
favorite
models.py
class PostJob(models.Model):
job_title = models.CharField(max_length=256)
job_description = models.TextField()
key_skills = models.TextField()
job_type = models.IntegerField()
offered_salary_range = models.CharField(max_length=256,blank=True,null=True)
experience_range = models.CharField(max_length=256,blank=True,null=True)
education = models.CharField(max_length=256,blank=True,null=True)
industry = models.CharField(max_length=256,blank=True,null=True)
application_acceptence_date = models.CharField(max_length=256,blank=True,null=True)
additional_skills = models.CharField(max_length=256,blank=True,null=True)
job_posted_by = models.CharField(max_length=256,blank=True,null=True)
job_posters_email = models.CharField(max_length=256,blank=True,null=True)
company = models.ForeignKey(access_models.EmployerRegister,on_delete=models.CASCADE,related_name='post_jobs',null=True,blank=True)
def __str__(self):
return self.job_title
documents.py
from django_elasticsearch_dsl import DocType, Index
# from seeker.models import AppliedJobs
from employer.models import PostJob
# from access.models import SeekerRegister
jobs = Index('jobs')
@jobs.doc_type
class AppliedJobsDocument(DocType):
class Meta:
model = PostJob
fields = [
'job_title',
'job_description',
'key_skills',
'job_type',
'offered_salary_range',
'experience_range',
'education',
'industry',
'application_acceptence_date',
'additional_skills',
'job_posted_by',
'job_posters_email',
]
views.py
from .documents import AppliedJobsDocument
from django.http import JsonResponse
def search_applied_jobs(request):
q = request.GET.get('q')
print(q)
jobs = AppliedJobsDocument.search().query("match", title=q)
lst=
dict ={}
for i in jobs:
print(i)
return JsonResponse(lst,safe=False)
settings.py:
ELASTICSEARCH_DSL = {
'default': {
'hosts': 'localhost:9200'
},
}
i have added 'django_elasticsearch_dsl' in the APP also
i am trying to use elastic search with django and above is my codes.
i my database there is records but i am getting empty data when i am trying to print
it in my console.
i have installed java and elastic search is coming in port localhost:9200 also
please have a look into my code.
python django elasticsearch
add a comment |
up vote
1
down vote
favorite
models.py
class PostJob(models.Model):
job_title = models.CharField(max_length=256)
job_description = models.TextField()
key_skills = models.TextField()
job_type = models.IntegerField()
offered_salary_range = models.CharField(max_length=256,blank=True,null=True)
experience_range = models.CharField(max_length=256,blank=True,null=True)
education = models.CharField(max_length=256,blank=True,null=True)
industry = models.CharField(max_length=256,blank=True,null=True)
application_acceptence_date = models.CharField(max_length=256,blank=True,null=True)
additional_skills = models.CharField(max_length=256,blank=True,null=True)
job_posted_by = models.CharField(max_length=256,blank=True,null=True)
job_posters_email = models.CharField(max_length=256,blank=True,null=True)
company = models.ForeignKey(access_models.EmployerRegister,on_delete=models.CASCADE,related_name='post_jobs',null=True,blank=True)
def __str__(self):
return self.job_title
documents.py
from django_elasticsearch_dsl import DocType, Index
# from seeker.models import AppliedJobs
from employer.models import PostJob
# from access.models import SeekerRegister
jobs = Index('jobs')
@jobs.doc_type
class AppliedJobsDocument(DocType):
class Meta:
model = PostJob
fields = [
'job_title',
'job_description',
'key_skills',
'job_type',
'offered_salary_range',
'experience_range',
'education',
'industry',
'application_acceptence_date',
'additional_skills',
'job_posted_by',
'job_posters_email',
]
views.py
from .documents import AppliedJobsDocument
from django.http import JsonResponse
def search_applied_jobs(request):
q = request.GET.get('q')
print(q)
jobs = AppliedJobsDocument.search().query("match", title=q)
lst=
dict ={}
for i in jobs:
print(i)
return JsonResponse(lst,safe=False)
settings.py:
ELASTICSEARCH_DSL = {
'default': {
'hosts': 'localhost:9200'
},
}
i have added 'django_elasticsearch_dsl' in the APP also
i am trying to use elastic search with django and above is my codes.
i my database there is records but i am getting empty data when i am trying to print
it in my console.
i have installed java and elastic search is coming in port localhost:9200 also
please have a look into my code.
python django elasticsearch
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
models.py
class PostJob(models.Model):
job_title = models.CharField(max_length=256)
job_description = models.TextField()
key_skills = models.TextField()
job_type = models.IntegerField()
offered_salary_range = models.CharField(max_length=256,blank=True,null=True)
experience_range = models.CharField(max_length=256,blank=True,null=True)
education = models.CharField(max_length=256,blank=True,null=True)
industry = models.CharField(max_length=256,blank=True,null=True)
application_acceptence_date = models.CharField(max_length=256,blank=True,null=True)
additional_skills = models.CharField(max_length=256,blank=True,null=True)
job_posted_by = models.CharField(max_length=256,blank=True,null=True)
job_posters_email = models.CharField(max_length=256,blank=True,null=True)
company = models.ForeignKey(access_models.EmployerRegister,on_delete=models.CASCADE,related_name='post_jobs',null=True,blank=True)
def __str__(self):
return self.job_title
documents.py
from django_elasticsearch_dsl import DocType, Index
# from seeker.models import AppliedJobs
from employer.models import PostJob
# from access.models import SeekerRegister
jobs = Index('jobs')
@jobs.doc_type
class AppliedJobsDocument(DocType):
class Meta:
model = PostJob
fields = [
'job_title',
'job_description',
'key_skills',
'job_type',
'offered_salary_range',
'experience_range',
'education',
'industry',
'application_acceptence_date',
'additional_skills',
'job_posted_by',
'job_posters_email',
]
views.py
from .documents import AppliedJobsDocument
from django.http import JsonResponse
def search_applied_jobs(request):
q = request.GET.get('q')
print(q)
jobs = AppliedJobsDocument.search().query("match", title=q)
lst=
dict ={}
for i in jobs:
print(i)
return JsonResponse(lst,safe=False)
settings.py:
ELASTICSEARCH_DSL = {
'default': {
'hosts': 'localhost:9200'
},
}
i have added 'django_elasticsearch_dsl' in the APP also
i am trying to use elastic search with django and above is my codes.
i my database there is records but i am getting empty data when i am trying to print
it in my console.
i have installed java and elastic search is coming in port localhost:9200 also
please have a look into my code.
python django elasticsearch
models.py
class PostJob(models.Model):
job_title = models.CharField(max_length=256)
job_description = models.TextField()
key_skills = models.TextField()
job_type = models.IntegerField()
offered_salary_range = models.CharField(max_length=256,blank=True,null=True)
experience_range = models.CharField(max_length=256,blank=True,null=True)
education = models.CharField(max_length=256,blank=True,null=True)
industry = models.CharField(max_length=256,blank=True,null=True)
application_acceptence_date = models.CharField(max_length=256,blank=True,null=True)
additional_skills = models.CharField(max_length=256,blank=True,null=True)
job_posted_by = models.CharField(max_length=256,blank=True,null=True)
job_posters_email = models.CharField(max_length=256,blank=True,null=True)
company = models.ForeignKey(access_models.EmployerRegister,on_delete=models.CASCADE,related_name='post_jobs',null=True,blank=True)
def __str__(self):
return self.job_title
documents.py
from django_elasticsearch_dsl import DocType, Index
# from seeker.models import AppliedJobs
from employer.models import PostJob
# from access.models import SeekerRegister
jobs = Index('jobs')
@jobs.doc_type
class AppliedJobsDocument(DocType):
class Meta:
model = PostJob
fields = [
'job_title',
'job_description',
'key_skills',
'job_type',
'offered_salary_range',
'experience_range',
'education',
'industry',
'application_acceptence_date',
'additional_skills',
'job_posted_by',
'job_posters_email',
]
views.py
from .documents import AppliedJobsDocument
from django.http import JsonResponse
def search_applied_jobs(request):
q = request.GET.get('q')
print(q)
jobs = AppliedJobsDocument.search().query("match", title=q)
lst=
dict ={}
for i in jobs:
print(i)
return JsonResponse(lst,safe=False)
settings.py:
ELASTICSEARCH_DSL = {
'default': {
'hosts': 'localhost:9200'
},
}
i have added 'django_elasticsearch_dsl' in the APP also
i am trying to use elastic search with django and above is my codes.
i my database there is records but i am getting empty data when i am trying to print
it in my console.
i have installed java and elastic search is coming in port localhost:9200 also
please have a look into my code.
python django elasticsearch
python django elasticsearch
asked 22 hours ago
soubhagya
335
335
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You need to first index your data from database into elasticsearch. Then you will be able to execute queries on elasticsearch.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You need to first index your data from database into elasticsearch. Then you will be able to execute queries on elasticsearch.
add a comment |
up vote
1
down vote
accepted
You need to first index your data from database into elasticsearch. Then you will be able to execute queries on elasticsearch.
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You need to first index your data from database into elasticsearch. Then you will be able to execute queries on elasticsearch.
You need to first index your data from database into elasticsearch. Then you will be able to execute queries on elasticsearch.
answered 17 hours ago
n1rna
1072
1072
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372109%2fdjango-elasticsearch-giving-empty-records-while-the-database-has-records%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown