-
Notifications
You must be signed in to change notification settings - Fork 803
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
Added support for the semantic_text
field and semantic
query type
#1881
Added support for the semantic_text
field and semantic
query type
#1881
Conversation
|
||
name: str | ||
summary: str | ||
content: Any = dsl.mapped_field( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm typing the semantic text field as Any
because it has different types during ingest and search. On ingest it is a plain string, while on search it is returned as an object with the original string in the text
attribute. The object also includes an inference
attribute with the autogenerated chunks and their embeddings.
99d091f
to
bb99b1c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM.
examples/async/semantic_text.py
Outdated
|
||
|
||
async def search(query: str) -> dsl.AsyncSearch[WorkplaceDoc]: | ||
return WorkplaceDoc.search()[:5].query( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Doing [:5]
before the query call is a bit confusing IMO.
examples/async/semantic_text.py
Outdated
|
||
async def search(query: str) -> dsl.AsyncSearch[WorkplaceDoc]: | ||
return WorkplaceDoc.search()[:5].query( | ||
"semantic", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to use the class here? One advantage is that it avoids typos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason at all, except that historically it has been preferred to use the names. I actually prefer the classes myself and started using them on my tests. I'll update this.
…#1881) (#1882) * Added support for the `semantic_text` field and `semantic` query type * Fix nltk code... again * feedback (cherry picked from commit 7fa4f8c) Co-authored-by: Miguel Grinberg <[email protected]>
…elastic#1881) * Added support for the `semantic_text` field and `semantic` query type * Fix nltk code... again * feedback
This change adds support for semantic text, introduced in Elasticsearch 8.15, plus an example application. Unfortunately running this application requires a somewhat beefy ES instance, so I'm not going to add integration tests.