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

Another try at fixing path prompting #844

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/sycamore/sycamore/query/operators/query_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class QueryDatabase(LogicalOperator):
},
{
"match": {
"properties.path.keyword": "/path/to/data/*.pdf",
"properties.path": "/path/to/data/*.pdf",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused by this. We want is to use the .keyword version of the field so the wildcard match will work. I realize more few-shots may be needed to get this dialed in but I don't think you want to take .keyword out here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Near as I can tell wildcard match doesn't work.

https://opensearch.org/docs/latest/field-types/supported-field-types/keyword/
says "A keyword field type contains a string that is not analyzed. It allows only exact, case-sensitive matches."

When LUNA tried *22* in a keyword match it got nothing back despite there being a path that matches that.

This change made path matching work properly on all the test cases I have for the customer. The two main patterns were match 1 file or match 2 files. Depending on the variant of the prompt it would work for one of those or the other. With this prompt it has worked for both in all cases I've tried.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry. The correct syntax is:

{"query": {"wildcard": {"properties.path.keyword": "/path/to/data/*.pdf"}}}

That is, it needs the wildcard, not match operator, for this to work.

$ curl --insecure -u admin:admin -X GET "https://localhost:9200/const_ntsb/_search" -d '{"query": {"wildcard": {"properties.path.keyword": "s3://aryn-public/ntsb/*3*.pdf"}}}' -H 'Content-Type: application/json' | python -m json.tool | grep 'path'

                        "path": "s3://aryn-public/ntsb/73.pdf",
                        "path": "s3://aryn-public/ntsb/3.pdf",
                        "path": "s3://aryn-public/ntsb/31.pdf",
                        "path": "s3://aryn-public/ntsb/31.pdf",
                        "path": "s3://aryn-public/ntsb/34.pdf",
                        "path": "s3://aryn-public/ntsb/35.pdf",
                        "path": "s3://aryn-public/ntsb/36.pdf",
                        "path": "s3://aryn-public/ntsb/37.pdf",
                        "path": "s3://aryn-public/ntsb/37.pdf",
                        "path": "s3://aryn-public/ntsb/43.pdf",
                        

"properties.entity.location": "Georgia"
}
}
Expand All @@ -42,8 +42,8 @@ class QueryDatabase(LogicalOperator):
}
}

Use the ".keyword" subfield for "properties.path", as this field represents the filename of the
original document, and is generally accessed as a keyword field.
Any time you would use the field properties.path for an exact match, instead use the field
properties.path.keyword and make sure to include the full path.

The full range of OpenSearch Query DSL parameters are supported.
Whenever possible, use the query parameter to filter data at the source, as this is more
Expand Down
Loading