Filter and search through python

Hi,

I'm new to elasticsearch, I'm using elasticsearch for semantic search. I have pushed 5pdf files after converting into vector. when I do search i'm not getting right index value.

so, I thought I would do the filter and search. can someone tell me how to do filter and search

columns names : id, product_text_description, product_vector_description, product_name

here, I want to filter first like product_name=='mobile' and then do search on top of it.

can someone provide/help json query?

I'm using python api to do search

Hi @IamExperimenting_Now Welcome to the community

These are big questions

I would suggest the really cool / informative Elastic Labs

There is even a Hybrid Search Example which I think you may be talking about it might be good to look through

We have a lot of content on this subject

1 Like

Hi @stephenb thanks for your reply and article, I went through those elasticsearch lab github pages, but one few .ipynb files are viewable and others are showing "invalid notebook". Anyway thanks for it.

I have question, just want to make sure whether my approach is correct or not.

currently, I have pushed 5 pdf files by creating chunks. Now, I'm planning to do the search after filtering the data inside elasticsearch vector database like rather querying on entire vector database I thought I would do the filter first and then do the search.

is it possible?

query = {
   "query" : {
        "bool" : {
            "filter" : {
                 "term" : {"product_name" : "mobile"}
          }
     }
  },

"knn" : {
   "field" : "product_vector_description",
   "query_vector" : model.encode("what is the specification mobile model xxxx?"),
   "k" : 3
   } 
}

the above query I used to do the search but unfortunately, I'm getting error. could you please help.

Also I tried to split and work, just to check whether I'm able to filter the vector database or not, fortunately, I was able to do the filter.

for that, I used the below query.

query = {
   "query" : {
        "bool" : {
            "filter" : {
                 "term" : {"product_name" : "mobile"}
          }
     }
  }
}

We Can't help without the error

I would suggest perhaps going to Kibana Dev - Tools and test your queries there before trying the python

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.