Quantcast
Channel: Weaviate Community Forum - Latest posts
Viewing all articles
Browse latest Browse all 3588

Searching with bm25 does not return all results with GeoCoordinate filter

$
0
0

hi @Bryan_Jenson !

What version are you using?

Check out this code I did to reproduce this scenario:

import weaviate
from weaviate import classes as wvc
import os
client = weaviate.connect_to_local()
print(weaviate.__version__, client.get_meta().get("version"))

client.collections.delete("Geo")
collection = client.collections.create(
    "Geo",
    vectorizer_config=wvc.config.Configure.Vectorizer.none(),
    properties=[
        wvc.config.Property(name="location", data_type=wvc.config.DataType.GEO_COORDINATES)
    ]
)

locations = [
    {"longitude": -111.65492248535156, "latitude": 40.11495590209961},
    {"longitude": -111.89215850830078, "latitude": 40.871612548828125},
    {"longitude": -111.89104461669922, "latitude": 40.760780334472656},
    {"longitude": -111.88826751708984, "latitude": 40.718833923339844},
    {"longitude": -111.61075592041016, "latitude": 40.16523361206055},
    {"longitude": -111.89215850830078, "latitude": 40.871612548828125},
    {"longitude": -111.89215850830078, "latitude": 40.871612548828125},
    {"longitude": -111.89215850830078, "latitude": 40.871612548828125},
    {"longitude": -111.89215850830078, "latitude": 40.871612548828125},
    {"longitude": -111.89215850830078, "latitude": 40.871612548828125},
    {"longitude": -111.89215850830078, "latitude": 40.871612548828125},
    {"longitude": -111.89215850830078, "latitude": 40.871612548828125},
    {"longitude": -111.89104461669922, "latitude": 40.760780334472656},
    {"longitude": -111.89215850830078, "latitude": 40.871612548828125},
    {"longitude": -111.89104461669922, "latitude": 40.760780334472656},
    {"longitude": -111.89215850830078, "latitude": 40.871612548828125},
    {"longitude": -111.65853118896484, "latitude": 40.23384475708008},
    {"longitude": -111.89104461669922, "latitude": 40.760780334472656},
    {"longitude": -111.89104461669922, "latitude": 40.760780334472656},
    {"longitude": -111.89104461669922, "latitude": 40.760780334472656},
    {"longitude": -111.61075592041016, "latitude": 40.16523361206055},
    {"longitude": -111.89104461669922, "latitude": 40.760780334472656}
]

with client.batch.dynamic() as batch:
    for location in locations:
        batch.add_object(
            collection="Geo",
            properties={
                "location": wvc.data.GeoCoordinate(
                    latitude=location.get("latitude"),
                    longitude=location.get("longitude")
                )
            }
        )

print("Errors found", client.batch.failed_objects)

print("Indexed", collection.aggregate.over_all())

query = collection.query.fetch_objects(
    filters=(
        wvc.query.Filter.by_property("location").within_geo_range(
            wvc.data.GeoCoordinate(
                latitude=40.76066207885742,
                longitude=-111.89395141601562,
            ),
            distance=321868
        )
    )
)
print("Found", len(query.objects))

This was the output:

Client: 4.9.2, Server: 1.27.0
Errors found []
Indexed AggregateReturn(properties={}, total_count=22)
Found 22

Viewing all articles
Browse latest Browse all 3588

Trending Articles