Skip to content

Document.from_dict doesn't has type info. #47

Closed
@saukymo

Description

@saukymo

Test with below code:

class TestUnsignedField:
    def test_query_from_unsigned_field(self):
        schema = SchemaBuilder().add_unsigned_field("order", indexed=True).build()

        index = Index(schema)

        writer = index.writer()

        doc = Document.from_dict({"order": 1})

        writer.add_document(doc)
        writer.commit()
        index.reload()

        query = index.parse_query("order:1", ["order"])
        result = index.searcher().search(query, 1)
        assert len(result.hits) == 1

The extract_value in document.rs will try to interpret it as i64 at first while it should be interpreted as u64. We may need to pass schema into from_dict.

I also met this issue when I try to support json field where it interpreted the field as String at first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions