Invalid search term for fetch_objects

Description

I am using a fetch_objects call as follows:

    try:
        res = multi_tenant.query.fetch_objects(
            filters=(Filter.by_property("from").equal("I") &
                Filter.by_property("relationship").equal("do")  &
                Filter.by_property("to").equal("it")),
            limit=1,
            return_properties = ["relationship"]
        )

        if len(res.objects) > 0:
            return res.objects[0].uuid
        return None
    except weaviate.exceptions.WeaviateQueryError as e:
        print(f"Error fetching connection - {e}")
        raise Exception(e)

I see this error:

‘Query call with protocol GRPC search failed with message explorer: list class: search: object search at index triple: local shard object search triple_Yambina_Limited__Admin: nested query: nested clause at pos 1: invalid search term, only stopwords provided. Stopwords can be configured in class.invertedIndexConfig.stopwords.’

in the WeaviateQueryError.

Not at all clear what is wrong, the syntax I am using looks OK?

Server Setup Information

  • Weaviate Server Version: semitechnologies/weaviate:1.24.10
  • Deployment Method: docker
  • Multi Node? Number of Running Nodes: 1
  • Client Language and Version: python API V4

Any additional Information

hi @olddave ! Welcome to our community :hugs:

I believe the issue here is that one of the parameters provided in your query seems to be present in the EN stopwords:

I believe you can work around this by removing it from the stopwords.

Let me know if this helps!

Thanks!

Hi,

It would help if I was using V3 of the API. There is no equivalent for V4 of the API. I went digging around in the source code for V4 and cannot find the equivalent of the “schema” module nor a way to control the stopwords. Can you help?

Cheers

Hi @olddave,
That is a good point. :+1:

I only found this example, which shows how to update a collection with stopwords. Which is not a lot to go by.

We will update the docs to add v4 examples showing how to work with inverted indexes. :pray:

Here are some examples on how you should be able to do it with the V4 Python client.

Create a collection – with an Inverted Index

from weaviate.classes.config import Configure

client.collections.create(
    name="Articlezz",
    vectorizer_config=Configure.Vectorizer.text2vec_openai(),
    inverted_index_config=Configure.inverted_index(
        stopwords_additions=["skip", "me"], # this adds new stopwords
        stopwords_removals=["a", "the"], # this removes stopwords
    )
)

Create a collection – with an Inverted Index and Stopword Preset

from weaviate.classes.config import Configure, StopwordsPreset

client.collections.create(
    name="Articlezz",
    vectorizer_config=Configure.Vectorizer.text2vec_openai(),
    inverted_index_config=Configure.inverted_index(
        stopwords_preset=StopwordsPreset.EN,
        stopwords_additions=["skip", "me"], # this adds stopwords to be ignored
        stopwords_removals=["a", "the"], # this removes stopwords from the exclusion list
    )
)

Update a collection – reconfigure inverted index

You don’t need to recreate your collections to modify your stopwords, you can update the configuration on an existing collection.

from weaviate.classes.config import Reconfigure

# Get the Article collection object
articles = client.collections.get("Article")

# Update the collection configuration
articles.config.update(
    # Note, use Reconfigure here (not Configure)
    inverted_index_config=Reconfigure.inverted_index(
        stopwords_additions=["skip", "me"], # this adds stopwords
        stopwords_removals=["a", "the"],    # this removes stopwords
    )
)

I hope this helps