Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fuzzy in a SameElement Search of a map or struct #33238

Closed
LuisaWetzel opened this issue Feb 3, 2025 · 5 comments
Closed

Use fuzzy in a SameElement Search of a map or struct #33238

LuisaWetzel opened this issue Feb 3, 2025 · 5 comments
Assignees
Milestone

Comments

@LuisaWetzel
Copy link

Describe the bug
I want to combine the sameElement and Fuzzy Search on a map or struct field. Trying to do so I get the response that the serializing of FuzzyItem in same_element is not implemented.

To Reproduce
Steps to reproduce the behavior:

  1. Create the schema:
schema doc {
    document doc {
        field data type map<string, string> {
            indexing: summary
            struct-field key    { indexing: attribute }
            struct-field value  { indexing: attribute }
        }
    }
    fieldset default {
        fields: data
    }
}
  1. Run the following Query:
{
	"yql": "select * from sources doc where data contains sameElement(key contains 'some key', value contains({maxEditDistance:2}fuzzy('Some value')))",
	"tracelevel": 5
}
  1. See error

YQL query parsed: [Invalid query: Serializing of FuzzyItem in same_element is not implemented, please report this as a bug.]
Illegal Query: FUZZY(Some value,2,0,false) value:Some value field is not a string attribute

Full Response:

{
	"trace": {
		"children": [
			{
				"message": "No query profile is used"
			},
			{
				"message": "Invoking chain 'vespa' [com.yahoo.prelude.statistics.StatisticsSearcher@native -> com.yahoo.prelude.querytransform.PhrasingSearcher@vespa -> ... -> federation@native]"
			},
			{
				"children": [
					{
						"message": "YQL query parsed: [Invalid query: Serializing of FuzzyItem in same_element is not implemented, please report this as a bug.]"
					},
					{
						"message": "Federating to [text]"
					},
					{
						"message": "Ignoring fill(null): Hits are unfillable: result.hits().getFilled()=null"
					},
					{
						"message": "Query time query 'data:{key:some key value:Some value}': 2 ms"
					},
					{
						"message": "Summary fetch time query 'data:{key:some key value:Some value}': 0 ms"
					}
				]
			}
		]
	},
	"root": {
		"id": "toplevel",
		"relevance": 1.0,
		"fields": {
			"totalCount": 0
		},
		"errors": [
			{
				"code": 3,
				"summary": "Illegal query",
				"source": "text",
				"message": "FUZZY(Some value,2,0,false) value:Some value field is not a string attribute"
			}
		]
	}
}

Expected behavior
I am able to use fuzzy in the sameElement Search which performs a fuzzy search on the attribute Field of the map or struct.

Environment (please complete the following information):
Dockerized vespa

Vespa version
Vespa version: 8.471.25

Additional context
this works:

{
	"yql": "select * from sources doc where data.value contains({maxEditDistance:2}fuzzy('Some value'))",
	"tracelevel": 3
}

and this works:

{
	"yql": "select * from sources doc where data contains sameElement(key contains 'some key', value contains 'some value')",
	"tracelevel": 3
}
@bratseth
Copy link
Member

bratseth commented Feb 4, 2025

The missing serialization is fixed in 8.473.18 which should be available later today.
Please let us know if this solves your problem.

@hmusum hmusum added this to the soon milestone Feb 5, 2025
@LuisaWetzel
Copy link
Author

I tested it, and the serialization message is gone, but I still get the error: "FUZZY(Some Value,2,0,false) value: Some Value field is not a string attribute," even though I can use fuzzy directly on data.value.

Vespa version: 8.475.11

The same query on the same document leads to the following response:

{
	"trace": {
		"children": [
			{
				"message": "No query profile is used"
			},
			{
				"message": "Invoking chain 'vespa' [com.yahoo.prelude.statistics.StatisticsSearcher@native -> com.yahoo.prelude.querytransform.PhrasingSearcher@vespa -> ... -> federation@native]"
			},
			{
				"children": [
					{
						"message": "YQL query parsed: [select * from doc where data contains sameElement(key contains \"some key\", value contains fuzzy(\"Some value\"))]"
					},
					{
						"message": "Federating to [text]"
					},
					{
						"message": "Ignoring fill(null): Hits are unfillable: result.hits().getFilled()=null"
					},
					{
						"message": "Query time query 'data:{key:some key value:Some value}': 7 ms"
					},
					{
						"message": "Summary fetch time query 'data:{key:some key value:Some value}': 0 ms"
					}
				]
			}
		]
	},
	"root": {
		"id": "toplevel",
		"relevance": 1.0,
		"fields": {
			"totalCount": 0
		},
		"errors": [
			{
				"code": 3,
				"summary": "Illegal query",
				"source": "text",
				"message": "FUZZY(Some value,2,0,false) value:Some value field is not a string attribute"
			}
		]
	}
}

@bratseth
Copy link
Member

Thank you, this time we (@vekterli) verified this on our side. It should work for indexed search on 8.479. Let us know if you require this for streaming.

@LuisaWetzel
Copy link
Author

It works fine now, thank you.

@vekterli
Copy link
Member

For reference, test was added in vespa-engine/system-test#4345

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants