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

PoC DO NOT MERGE - Use root object for storing field inference #10

Conversation

carlosdelest
Copy link
Owner

@carlosdelest carlosdelest commented Nov 1, 2023

PoC demoed in GenAI meeting 01/11/2023.

Modifies #9 by creating a root level object for storing inference results.

It also adds a crude source exclude mechanism so the root field is hidden from the user when source fetching is not specified.

For the following index:

PUT test-semantic
{
    "mappings": {
        "properties": {
            "infer_field": {
                "type": "semantic_text",
                "model_id": "my-elser-model"
            },
            "non_infer_field": {
                "type": "text"
            },
            "another_infer_field": {
                "type": "semantic_text",
                "model_id": "my-elser-model"
            }
        }
    }
}

A document ingestion like:

PUT test-semantic/_doc/doc1
{
    "infer_field": "these are not the droids you're looking for",
    "non_infer_field": "he can go about his business",
    "another_infer_field": "move along"
}

will look like this once ingested:

GET test-semantic/_doc/doc1?_source_includes=*
{
  "_index": "test-semantic",
  "_id": "doc1",
  "_version": 1,
  "_seq_no": 0,
  "_primary_term": 1,
  "found": true,
  "_source": {
    "_semantic_text_inference": {
      "infer_field": {
        "lucas": 0.05212344,
        "ty": 0.041213956,
        "dragon": 0.50991,
        "type": 0.23241979,
        "dr": 1.9312073,
        "##o": 0.2797593,
        "these": 1.1422911,
        "robot": 0.3821148
      },
      "another_infer_field": {
        "play": 0.32950363,
        "hum": 0.003634397,
        "tempo": 0.15531318,
        "anger": 0.028992891,
        "soon": 0.37861174,
        "crawl": 0.10688804,
        "road": 0.10052208,
        "action": 0.18112859,
        "talk": 0.48378038,
        "up": 0.17651497,
        "moving": 1.8461642
      }
    },
    "infer_field": "these are not the droids you're looking for",
    "another_infer_field": "move along",
    "non_infer_field": "he can go about his business"
  }
}

Root level field is hidden automatically unless source fetching is specified:

GET test-semantic/_doc/doc1
{
  "_index": "test-semantic",
  "_id": "doc1",
  "_version": 1,
  "_seq_no": 0,
  "_primary_term": 1,
  "found": true,
  "_source": {
    "infer_field": "these are not the droids you're looking for",
    "another_infer_field": "move along",
    "non_infer_field": "he can go about his business"
  }
}

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

Successfully merging this pull request may close these issues.

1 participant