Using Natural Language to Query Weaviate (self querying)

There was a great question on the slack channel that I thought other users might benefit from so I’ve moved it here as well. The question is as follows:

“Say in weaviate, I have class Products which has various products like watch, mobile, smart watch etc
Will weaviate be able to answer queries like
a) Cheapest smart watch
b) costliest smart watch
c) Smart watch between 10 $ and 20 $
if yes, please advise me on how can i use weaviate to achieve this”

The way to achieve this with Weaviate is to use the self-querying functionality via LangChain. This basically takes the natural language queries you see above and translates them into equivalent GraphQL queries (using a LLM) that can be run in Weaviate. You can see a tutorial on how to set this up here:


I just posted a question related to this. This is what I am prototyping. So langchain converts the NLP string, "Has Greta Gerwig directed any movies about women " into a query like

query='women' filter=Comparison(comparator=<Comparator.EQ: 'eq'>, attribute='director', value='Greta Gerwig') limit=None

What should be the Weaviate schema look like for this data structure langchain example?