Hi~! I’m testing vector search using weaviate for the first time.
In other general search system(ex Elasticsearch), we decide which field to search for in query.
But in weaviate, fields set to indexSearchable True are unconditionally searched and reflected in scoring?
I’m looking at the guide and it doesn’t seem to indicate which field to search for other than specifying a path in the filter.
please help me
Hi @SeungMin_Baek ! Welcome to our community
So, consider you can search in two separate ways, and later even combine them in hybrid search.
In general words:
For Vector/Similarity search, Weaviate will:
- get the property value and it’s name (or not, depending of your configuration. see skip:True and vectorizePropertyName)
- concatenate all that resulting content
- send it to an inference model
- get back the vectors for all that concatenated content
- index it in a, eg, HNSW index.
Now you can do similariy search. meaning, if you query for “Biggest city in Brazil”, Weaviate will:
- Vectorize your query
- Search your query vector against your objects vectors
- Do all sorts of calculation
- Bring back the closest results
You can also do keyword searches, using filters or bm25, for example, that will give you the closest objects in a different way.
Now, for bm25, you can choose wich fields it will search for. For example, from here:
jeopardy = client.collections.get("JeopardyQuestion")
response = jeopardy.query.bm25(
query="safety",
query_properties=["question"],
return_metadata=wvc.query.MetadataQuery(score=True),
limit=3
)
for o in response.objects:
print(o.properties)
print(o.metadata.score)
Ok. Now, in Weaviate, you can combine all that doing a hybrid search. Let’s say you want to query thru two fields, but want to weight in on a specific field. This is how you can do it from here:
jeopardy = client.collections.get("JeopardyQuestion")
response = jeopardy.query.hybrid(
query="food",
query_properties=["question^2", "answer"],
alpha=0.25,
limit=3
)
for o in response.objects:
print(o.properties)
Let me know if this helps
Also, check our events page, where you can learn a lot from our weekly and free events, online and in person:
Thanks!