Skip to content

Property 'type' not found #216

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

Closed
fuchaoqun opened this issue Mar 25, 2022 · 3 comments
Closed

Property 'type' not found #216

fuchaoqun opened this issue Mar 25, 2022 · 3 comments
Labels
Area: Specification Related to the API spec used to generate client code

Comments

@fuchaoqun
Copy link

Java API client version

8.1.1

Java version

17

Elasticsearch Version

7.17.1

Problem description

index json:

{
    "settings": {
        "analysis": {
            "filter": {
                "shingle_filter": {
                    "type": "shingle",
                    "min_shingle_size": 2,
                    "max_shingle_size": 3,
                    "output_unigrams": false
                }
            },
            "analyzer": {
                "shingle_analyzer": {
                    "tokenizer": "standard",
                    "filter": [
                        "shingle_filter"
                    ]
                }
            }
        }
    },
    "mappings": {
        "dynamic": "strict",
        "properties": {
            "id": {
                "type": "long"
            },
            "body": {
                "type": "text",
                "fields": {
                    "shingles": {
                        "type": "text",
                        "analyzer": "shingle_analyzer"
                    }
                }
            }
        }
    }
}
CreateIndexRequest createIndexRequest = CreateIndexRequest.of(b -> b
    .index(indexName)
    .withJson(new StringReader(jsonString))
);
jakarta.json.stream.JsonParsingException: Property 'type' not found
	at co.elastic.clients.json.JsonpUtils.lookAheadFieldValue(JsonpUtils.java:170) ~[elasticsearch-java-8.1.1.jar:na]
	at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:184) ~[elasticsearch-java-8.1.1.jar:na]
	at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:137) ~[elasticsearch-java-8.1.1.jar:na]
	at co.elastic.clients.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:75) ~[elasticsearch-java-8.1.1.jar:na]
	at co.elastic.clients.json.BuildFunctionDeserializer.deserialize(BuildFunctionDeserializer.java:47) ~[elasticsearch-java-8.1.1.jar:na]
	at co.elastic.clients.json.DelegatingDeserializer$SameType.deserialize(DelegatingDeserializer.java:43) ~[elasticsearch-java-8.1.1.jar:na]
	at co.elastic.clients.json.JsonpDeserializerBase$StringMapDeserializer.deserialize(JsonpDeserializerBase.java:346) ~[elasticsearch-java-8.1.1.jar:na]
	at co.elastic.clients.json.JsonpDeserializerBase$StringMapDeserializer.deserialize(JsonpDeserializerBase.java:332) ~[elasticsearch-java-8.1.1.jar:na]

see: https://www.elastic.co/guide/en/elasticsearch/reference/master/analysis-custom-analyzer.html

  • For custom analyzers, use a type of custom or omit the type parameter.

add "type": "custom" can fix the problem, but the document shows it can be omitted

@swallez
Copy link
Member

swallez commented Mar 29, 2022

Thanks for reporting this. It's an issue in the API specification used to produce the Java code.

elastic/elasticsearch-specification#1589 has been opened to solve this issue, and the Java client will be updated once it's fixed.

@swallez swallez added the Area: Specification Related to the API spec used to generate client code label Mar 29, 2022
@bpenrod
Copy link

bpenrod commented Sep 16, 2022

FYI, this does not appear to have been fixed by the changes in the API spec. It still throws

Exception in thread "main" co.elastic.clients.json.JsonpMappingException: Error deserializing co.elastic.clients.elasticsearch._types.analysis.Analyzer: Property 'type' not found (JSON path: settings.analysis.analyzer.shingle_analyzer) (line no=13, column no=38, offset=368)

with Java Client version 8.4.1

Issues #392 and #361 look like they are this same unresolved issue

@l-trotta
Copy link
Contributor

l-trotta commented Feb 1, 2024

Closing this as it was fixed in most recent versions of the client. Thanks for the report!

@l-trotta l-trotta closed this as completed Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Specification Related to the API spec used to generate client code
Projects
None yet
Development

No branches or pull requests

4 participants