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

[BUG] index() complains on a different type that set up in mappings #780

Closed
PlkMarudny opened this issue May 24, 2024 · 3 comments
Closed

Comments

@PlkMarudny
Copy link

What is the bug?

I have an index with defined mappings, so no dynamic mapping happens, the interesting part is here:

labels: {
		type: 'nested',
		include_in_root: true, // this allows to search in 'labels' without filtering
		properties: {
			id: {
				type: 'keyword'
			},
			name: {
				type: 'text',
				analyzer: 'keyword',
				fields: {
					raw: {
						type: 'keyword'
					}
				}
			},
			confidence: {
				type: 'float',
				coerce: true
			},
			status: {
				type: 'keyword'
			},
			description: {
				type: 'text'
			}
		}
	},

I try to use index() function like below:


const doc = {
...
labels: [
...
 {
      "id": "6038157c0255e53459b0fa6c",
      "name": "Travel",
      "confidence": 100,
      "status": "Approved",
      "legacy_name": "Travel"
    },
...
] };

const updateResult = await openSearchClient.index({
		    index: openSearchIndex,
		    id: doc.id,
		    body: doc,
		    refresh: true,
		});

And OpenSearch throws an error:

illegal_argument_exception: [illegal_argument_exception] Reason: mapper [labels.confidence] cannot be changed from type [long] to [float],
err_meta_body:{"error":{"reason":"mapper [labels.confidence] cannot be changed from type [long] to [float]","root_cause":[{"reason":"mapper [labels.confidence] cannot be changed from type [long] to [float]","type":"illegal_argument_exception"}],"type":"illegal_argument_exception"},"status":400}

I suspect that the confidence: 100 is a problem, 100 being treated as long that cannot be coerced to float (but why?), however, the same document got indexed properly is used at /ans/_doc/id endpoint with a simple POST request.

How can one reproduce the bug?

What is the expected behavior?

I expect the document to be indexed.

What is your host/environment?

Windows 10, AWS hosted OpenSearch, Node client 2.8.0

Do you have any screenshots?

If applicable, add screenshots to help explain your problem.

Do you have any additional context?

100 value seems to be a number like any other number with decimal places in the document I try to index.

@nhtruong
Copy link
Collaborator

nhtruong commented Jun 3, 2024

Is this the print out of the index's mappings using GET /{index} endpoint?

labels: {
		type: 'nested',
		include_in_root: true, // this allows to search in 'labels' without filtering
		properties: {
			id: {
				type: 'keyword'
			},
			name: {
				type: 'text',
				analyzer: 'keyword',
				fields: {
					raw: {
						type: 'keyword'
					}
				}
			},
			confidence: {
				type: 'float',
				coerce: true
			},
			status: {
				type: 'keyword'
			},
			description: {
				type: 'text'
			}
		}
	},

@PlkMarudny
Copy link
Author

PlkMarudny commented Jun 3, 2024 via email

@dblock
Copy link
Member

dblock commented Jun 3, 2024

Let's close. If you can reproduce this outside of the client that'd be great @PlkMarudny.

@dblock dblock closed this as completed Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants