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.










share|improve this question


























    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.










    share|improve this question
























      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.










      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 22 hours ago









      soubhagya

      335




      335
























          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.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            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

























            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.






            share|improve this answer

























              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.






              share|improve this answer























                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.






                share|improve this answer












                You need to first index your data from database into elasticsearch. Then you will be able to execute queries on elasticsearch.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 17 hours ago









                n1rna

                1072




                1072






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

                    SQL update select statement

                    'app-layout' is not a known element: how to share Component with different Modules