Code Monkey home page Code Monkey logo

Comments (3)

zbloss avatar zbloss commented on July 21, 2024

It's almost as if the by_property().equal() is actually by_property().like() under the hood. I added another row of data without the string "Verified" in the status field. Still weaviate returns Not Verified & Verified but it does not print out the new entry.

import weaviate
import weaviate.classes as wvc

from weaviate.classes.config import Property, DataType

client = weaviate.connect_to_local()

# Note that you can use `client.collections.create_from_dict()` to create a collection from a v3-client-style JSON object
client.collections.create(
    "Question",
    properties=[
        Property(name="title", data_type=DataType.TEXT),
        Property(name="status", data_type=DataType.TEXT),
    ]
)

question_collection = client.collections.get("Question")

question_collection.data.insert({"title": "What is the capital of France?", "status": "Verified"})
question_collection.data.insert({"title": "What is the capital of Italy?", "status": "Not Verified"})
question_collection.data.insert({"title": "What is the capital of USA?", "status": "Washington DC"})


verified_questions = question_collection.query.fetch_objects(
    filters=wvc.query.Filter.by_property("status").equal("Verified"),
)

for question in verified_questions.objects:
    print(question.properties["status"])

"""
Returns:
------------

Verified
Not Verified
"""

from weaviate.

rthiiyer82 avatar rthiiyer82 commented on July 21, 2024

@zbloss : The search is a keyword search where it is looking to match the word 'Verified' in the objects stored in the database and hence you see 2 results "Verified and Not Verified" becuase these objects has keyword "Verified" in it. If you are looking to expect a specific object then I would suggest you to include multiple filters in your search. Let me know, what you think.

from weaviate.

parkerduckworth avatar parkerduckworth commented on July 21, 2024

Hey @zbloss 👋

Take a look at the Tokenizationsection in our docs. By default, the fields are tokenized by word, but for your usecase I would recommend tokenizing by field, which should give you the results you expect

from weaviate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.