Can only use prefix queries on keyword text and wildcard fields – not on – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 7.9-7.15

Briefly, this error occurs when you attempt to use a prefix query on a field type that doesn’t support it. Elasticsearch only allows prefix queries on keyword, text, and wildcard fields. If you’re trying to use it on a different field type, such as a number or date, you’ll encounter this error. To resolve this issue, you can either change the field type to one that supports prefix queries, or use a different type of query that is compatible with the current field type.

This guide will help you check for common problems that cause the log ” Can only use prefix queries on keyword; text and wildcard fields – not on [ ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: index.

Log Context

Log “Can only use prefix queries on keyword; text and wildcard fields – not on [” class name is MappedFieldType.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 return prefixQuery(value; method; false; context);
 }  public Query prefixQuery(String value; @Nullable MultiTermQuery.RewriteMethod method; boolean caseInsensitve;
 SearchExecutionContext context) {
 throw new QueryShardException(context; "Can only use prefix queries on keyword; text and wildcard fields - not on [" + name
 + "] which is of type [" + typeName() + "]");
 }  // Case sensitive form of wildcard query
 public final Query wildcardQuery(String value;

 

 [ratemypost]

Opster
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.