# Help to get the right syntax for query statement - from v3 client to v4 client

**URL:** <https://forum.weaviate.io/t/help-to-get-the-right-syntax-for-query-statement-from-v3-client-to-v4-client/3008>\
**Category:** Support\
**Created:** [July 10, 2024, 10:37pm UTC](https://forum.weaviate.io/t/help-to-get-the-right-syntax-for-query-statement-from-v3-client-to-v4-client/3008 "2024-07-10T22:37:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pon\_raj](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@pon\_raj](https://forum.weaviate.io/u/pon_raj)\
**Post date:** [July 10, 2024, 10:37pm UTC](https://forum.weaviate.io/t/help-to-get-the-right-syntax-for-query-statement-from-v3-client-to-v4-client/3008/1 "2024-07-10T22:37:47Z")

</div>

Hi,  
Please help to arrive the right weaviate client v4 sytnax for the below v3 client query statement.

V3 client query statement:

class\_name = “Yoga”  
response = (  
client.query  
.get(class\_name, [“document”])  
.with\_near\_text({‘concepts’ : [“Mahayana Buddhism”]})  
.do()  
)  
print(response[‘data’][‘Get’][class\_name][0][‘document’])

“Yoga” is the classification, and “document” is the property. I am trying to text match “Mahayana Buddhism”

It was working with v3 client but after v4 upgrade, I am unable to get the right query statement.

How do I get this working with v4 client?

Thanks.

---

<div class="post-metadata">

**Author:** ![Shahin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/shahin/32/7944_2.png) [@Shahin](https://forum.weaviate.io/u/Shahin)\
**Post date:** [July 11, 2024, 10:27am UTC](https://forum.weaviate.io/t/help-to-get-the-right-syntax-for-query-statement-from-v3-client-to-v4-client/3008/2 "2024-07-11T10:27:10Z")

</div>

Hi @pon_raj, I hope you having a nice day!

To perform near\_text search with Python Client v4, please use:

> yoga = client.collections.get(“Yoga”)  
> response = yoga.query.near\_text(  
> query=“Mahayana Buddhism”,  
> return\_metadata=MetadataQuery(distance=True)  
> )

> **[Vector similarity search | Weaviate - Vector Database](https://weaviate.io/developers/weaviate/search/similarity)**
>
> Vector search returns the objects with most similar vectors to that of the query.

I hope this helps, have a nice week!

---

<div class="post-metadata">

**Author:** ![pon\_raj](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@pon\_raj](https://forum.weaviate.io/u/pon_raj)\
**Post date:** [July 11, 2024, 3:11pm UTC](https://forum.weaviate.io/t/help-to-get-the-right-syntax-for-query-statement-from-v3-client-to-v4-client/3008/3 "2024-07-11T15:11:57Z")

</div>

Thank you for the help with v4 syntax. It works but response has objects no matter what I query. For an example, if I query non-existing text such as “abcaslkhas”, it returns objects.  
Do I need to add any additional attributes to the query so that it returns objects ony if the query string exists?  
Thanks.

---

<div class="post-metadata">

**Author:** ![Shahin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/shahin/32/7944_2.png) [@Shahin](https://forum.weaviate.io/u/Shahin)\
**Post date:** [July 12, 2024, 11:47am UTC](https://forum.weaviate.io/t/help-to-get-the-right-syntax-for-query-statement-from-v3-client-to-v4-client/3008/4 "2024-07-12T11:47:47Z")

</div>

Happy Friday @pon_raj !

So the `Near Text` operator is to find objects with the nearest vector to an input text.

Indeed you could insert some unrelated text and still retrieve an object because it vectorize the query input and it tries to find ‘ANN’ **approximate nearest neighbor** for vector-search queries.

The following operator can explain the distance in such search and shall return a far distance value:

> ```
> _additional {
> distance
> }   
> 
> ```

See here:

> **[Additional properties (metadata) | Weaviate - Vector Database](https://weaviate.io/developers/weaviate/api/graphql/additional-properties#distance)**
>
> Overview

However from what I understood you are trying to achieve, then I would highly recommend you → Hybrid Search which is the key to your case because Hybrid search results can favor the keyword component, the vector component or mix of both.

- Use `alpha` operator of `1` is a pure vector search or;
- An `alpha` of `0` is a pure keyword search or;
- Play with the value to lean more towards keyword or vector component!

> **[Hybrid search | Weaviate - Vector Database](https://weaviate.io/developers/weaviate/search/hybrid#balance-keyword-and-vector-search)**
>
> Hybrid search combines the results of a vector search and a keyword (BM25F) search by fusing the two result sets.

I hope this helps

---

<div class="post-metadata">

**Author:** ![pon\_raj](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@pon\_raj](https://forum.weaviate.io/u/pon_raj)\
**Post date:** [July 15, 2024, 12:05pm UTC](https://forum.weaviate.io/t/help-to-get-the-right-syntax-for-query-statement-from-v3-client-to-v4-client/3008/5 "2024-07-15T12:05:33Z")

</div>

Thank you for the helpful advice.
