<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Case insensitive search in elasticsearch</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=98667537" />
  <subtitle>Case insensitive search in elasticsearch</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=98667537</id>
  <updated>2026-04-05T11:58:47Z</updated>
  <dc:date>2026-04-05T11:58:47Z</dc:date>
  <entry>
    <title>RE: Case insensitive search in elasticsearch</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113771375" />
    <author>
      <name>Charalampos Chrysikopoulos</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113771375</id>
    <updated>2019-05-30T07:46:21Z</updated>
    <published>2019-05-30T07:46:21Z</published>
    <summary type="html">Hi Vilkram, sorry for the delay, I used simply the following code&lt;br /&gt;&lt;br /&gt;keyword = stringHelper.removeDiacritics(keyword).toLowerCase();&lt;br /&gt;&lt;br /&gt;And the removeDiacritics method:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    public String removeDiacritics(String text) {&lt;br /&gt;        if (StringUtils.isBlank(text))&lt;br /&gt;            return text;&lt;br /&gt;        String normalized = Normalizer.normalize(text, Normalizer.Form.NFD);&lt;br /&gt;        StringBuilder builder = new StringBuilder();&lt;br /&gt;        for (int i = 0; i &amp;lt; normalized.length(); i++) {&lt;br /&gt;            char c = normalized.charAt(i);&lt;br /&gt;            if (Character.getType(c) != Character.NON_SPACING_MARK) {&lt;br /&gt;                builder.append(c);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        return Normalizer.normalize(builder.toString(), Normalizer.Form.NFC);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;Hope it helps,&lt;br /&gt;Harry</summary>
    <dc:creator>Charalampos Chrysikopoulos</dc:creator>
    <dc:date>2019-05-30T07:46:21Z</dc:date>
  </entry>
  <entry>
    <title>RE: Case insensitive search in elasticsearch</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113577416" />
    <author>
      <name>Vikram Singla</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113577416</id>
    <updated>2019-05-09T04:22:23Z</updated>
    <published>2019-05-09T04:22:23Z</published>
    <summary type="html">How to lowercase the pattern?</summary>
    <dc:creator>Vikram Singla</dc:creator>
    <dc:date>2019-05-09T04:22:23Z</dc:date>
  </entry>
  <entry>
    <title>RE: Case insensitive search in elasticsearch</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113576749" />
    <author>
      <name>Vikram Singla</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113576749</id>
    <updated>2019-05-09T04:21:36Z</updated>
    <published>2019-05-09T04:21:36Z</published>
    <summary type="html">Can anybody tell how to apply case insensitive logic in wildcardquery in java code with an exmple?</summary>
    <dc:creator>Vikram Singla</dc:creator>
    <dc:date>2019-05-09T04:21:36Z</dc:date>
  </entry>
  <entry>
    <title>RE: Case insensitive search in elasticsearch</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111380006" />
    <author>
      <name>Brigden Nicholas</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111380006</id>
    <updated>2018-10-30T11:30:40Z</updated>
    <published>2018-10-30T11:30:40Z</published>
    <summary type="html">Matches documents that have fields that contain a term (not analyzed). So the search term will not be analyzed but on indexing Elasticsearch will analyze the field lowercase unless you define a custom mapping. So if you want to use a term query&amp;#8212; analyze the term on your own before querying. &lt;a href="https://prepaidgiftbalance.me/"&gt;&lt;span style="color: #000000"&gt;prepaidgiftbalance&lt;/span&gt;&lt;/a&gt;</summary>
    <dc:creator>Brigden Nicholas</dc:creator>
    <dc:date>2018-10-30T11:30:40Z</dc:date>
  </entry>
  <entry>
    <title>RE: Case insensitive search in elasticsearch</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=99287121" />
    <author>
      <name>Charalampos Chrysikopoulos</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=99287121</id>
    <updated>2017-11-23T11:01:00Z</updated>
    <published>2017-11-23T11:01:00Z</published>
    <summary type="html">Hi, again, the solution was very easy. I was not lowercasing the keywords in the search query...</summary>
    <dc:creator>Charalampos Chrysikopoulos</dc:creator>
    <dc:date>2017-11-23T11:01:00Z</dc:date>
  </entry>
  <entry>
    <title>RE: Case insensitive search in elasticsearch</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=99286801" />
    <author>
      <name>Charalampos Chrysikopoulos</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=99286801</id>
    <updated>2017-11-23T10:23:33Z</updated>
    <published>2017-11-23T10:23:33Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hi Jorge,&lt;br&gt;&lt;br&gt;thank you for your answer and sorry for the delay. Yes, I am searching in some fields of a web content structure. For example a field named "shortText". In elasticsearch the metadata for this field is&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;
"ddm__text__68549__shortText_en_GB": {
"analyzer": "english",
"term_vector": "with_positions_offsets",
"store": true,
"type": "string"
},
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;So in my case, the field should be analysed, as expected for a filed of a web content structure. &lt;br&gt;&lt;br&gt;The default Liferay search seems to work properly, so it searches case insensitive. So, the problem seems to be in my query and not in elastic search.&lt;br&gt;&lt;br&gt;Another problem that I have is that I cannot apply filters. I need to show only the web contents that have an English translation of the field "shortText". So, if I understand ES correctly, I need to use the "ExistsFilter" for this field and apply it on the top query. But it doesn't seem to work either.&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Charalampos Chrysikopoulos</dc:creator>
    <dc:date>2017-11-23T10:23:33Z</dc:date>
  </entry>
  <entry>
    <title>RE: Case insensitive search in elasticsearch</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=98677502" />
    <author>
      <name>Jorge Diaz</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=98677502</id>
    <updated>2017-11-15T12:23:58Z</updated>
    <published>2017-11-15T12:23:58Z</published>
    <summary type="html">Hi Charalampos,&lt;br /&gt;&lt;br /&gt;About your case sensitive search issue, are you searching in some particular field?&lt;br /&gt;&lt;br /&gt;The search behavior in Liferay for each field is configured by &lt;strong&gt;elasticsearch type mapping configuration&lt;/strong&gt;.&lt;br /&gt;Default configuration is:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="https://github.com/liferay/liferay-portal/blob/7.0.x/modules/apps/foundation/portal-search/portal-search-elasticsearch/src/main/resources/META-INF/mappings/liferay-type-mappings.json"&gt;modules/apps/foundation/portal-search/portal-search-elasticsearch/src/main/resources/META-INF/mappings/liferay-type-mappings.json&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;You have information about Elasticsearch mapping configuration in following link:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="https://www.elastic.co/guide/en/elasticsearch/guide/current/mapping-intro.html"&gt;https://www.elastic.co/guide/en/elasticsearch/guide/current/mapping-intro.html&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;In short words, basic configurations that Liferay uses are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;em&gt;&amp;#34;type&amp;#34;: &amp;#34;string&amp;#34; + &amp;#34;index&amp;#34;: &amp;#34;analyzed&amp;#34; =&amp;gt;&lt;/em&gt; standard analyzer is applied: &lt;a href="https://www.elastic.co/guide/en/elasticsearch/reference/2.4/analysis-standard-analyzer.html"&gt;https://www.elastic.co/guide/en/elasticsearch/reference/2.4/analysis-standard-analyzer.html&lt;/a&gt; (it lowercases the text)&lt;/li&gt;&lt;li&gt;&lt;em&gt;&amp;#34;type&amp;#34;: &amp;#34;string&amp;#34; + &amp;#34;index&amp;#34;: &amp;#34;not_analyzed&amp;#34; =&amp;gt;&lt;/em&gt; data is stored without modification&lt;/li&gt;&lt;li&gt;&lt;em&gt;&amp;#34;type&amp;#34;: &amp;#34;string&amp;#34; + &amp;#34;analyzer&amp;#34;: &amp;#34;keyword_lowercase&amp;#34; =&amp;gt;&lt;/em&gt; keyword_lowercase is applied (only lowercase of data)&lt;/li&gt;&lt;li&gt;&lt;em&gt;&amp;#34;type&amp;#34;: &amp;#34;string&amp;#34; + other specific language analyzer =&amp;gt;&lt;/em&gt; analyzers of specific languages are applied&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;So if you are searching in some field that is &amp;#34;not_analyzed&amp;#34; you won&amp;#39;t be able to do case insensitive search.&lt;br /&gt;but If you are searching in other field that uses the standard analyzer or the keyword_lowercase analyzer, data is lowercased, so you should be able to do case insensitive search.&lt;br /&gt;&lt;br /&gt;In order to verify the behavior, review the default configuration of the field you are using.&lt;br /&gt;&lt;br /&gt;If you want to change default elasticsearch type mapping configuration, go to &lt;strong&gt;control panel =&amp;gt; system settings =&amp;gt; foundation =&amp;gt; elasticsearch&lt;/strong&gt; and  configure:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;u&gt;Additional Type Mappings&lt;/u&gt;: add new type mappings of fields that are not included in default &lt;em&gt;liferay-type-mappings.json&lt;/em&gt;&lt;/li&gt;&lt;li&gt;&lt;u&gt;Override Type Mappings&lt;/u&gt;: overwrite type mappings of fields that are already included in default &lt;em&gt;liferay-type-mappings.json&lt;/em&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;After doing that changes, you have to reindex. &lt;img alt="emoticon" src="@theme_images_path@/emoticons/exclamation.gif" &gt;</summary>
    <dc:creator>Jorge Diaz</dc:creator>
    <dc:date>2017-11-15T12:23:58Z</dc:date>
  </entry>
  <entry>
    <title>Case insensitive search in elasticsearch</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=98667536" />
    <author>
      <name>Charalampos Chrysikopoulos</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=98667536</id>
    <updated>2017-11-15T10:01:16Z</updated>
    <published>2017-11-15T10:01:16Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hello,&lt;br&gt;&lt;br&gt;I am trying to run a search query in liferay DXP with the embedded elasticsearch, and my problem is that the search is not case insensitive. &lt;br&gt;&lt;br&gt;The search is done for web contents of a specific structure and template and on specific fields of this structure. I tried to apply my knowledge from 6.2 (with Solr), and it works ok, except of the case sensitivity.&lt;br&gt;&lt;br&gt;My code looks like this:&lt;br&gt;&lt;pre&gt;&lt;code&gt;
		 BooleanQuery fullQuery = BooleanQueryFactoryUtil.create(searchContext);
		
		 BooleanQuery searchQuery = BooleanQueryFactoryUtil.create(searchContext);
		 searchQuery.addRequiredTerm(Field.STATUS, WorkflowConstants.STATUS_APPROVED);
		 searchQuery.addRequiredTerm(Field.GROUP_ID, groupId);
		 searchQuery.addRequiredTerm("head", Boolean.TRUE);
		 if (Validator.isNotNull(searchContext.getEntryClassNames()) &amp;amp;amp;&amp;amp;amp; searchContext.getEntryClassNames().length &amp;amp;gt; 0)
		 {
		   searchQuery.addRequiredTerm(Field.ENTRY_CLASS_NAME, searchContext.getEntryClassNames()[0]);
		 }
		
		 if (Validator.isNotNull(ddmStructureKey)) {
		   searchQuery.addRequiredTerm("ddmStructureKey", ddmStructureKey);
		 }
		
		 if (Validator.isNotNull(ddmTemplateKey)) {
		   searchQuery.addRequiredTerm("ddmTemplateKey", ddmTemplateKey);
		 }

		BooleanQuery keywordQuery = new BooleanQueryImpl();
		WildcardQuery wildcardKeywordQuery = new WildcardQueryImpl(searchFieldName, keyword);
		WildcardQuery wildcardStarKeywordQuery = new WildcardQueryImpl(searchFieldName, "*" + keyword + "*");

		keywordQuery.add(wildcardKeywordQuery, BooleanClauseOccur.SHOULD);
		keywordQuery.add(wildcardStarKeywordQuery, BooleanClauseOccur.SHOULD);

		searchQuery.add(keywordQuery, BooleanClauseOccur.MUST);
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;So I thought that searching in the "searchFieldName" with "THI" as a keyword in a string "This is the string I am looking for", it should return at least the web content with this string. But I get this result only when searching with "Thi".&lt;br&gt;&lt;br&gt;I need to search with a wildcard query.&lt;br&gt;&lt;br&gt;Searching with the default search portlet works fine. Is there something in the API that has been changed, or is my code bad?&lt;br&gt;&lt;br&gt;Thank you in advance,&lt;br&gt;Harry&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Charalampos Chrysikopoulos</dc:creator>
    <dc:date>2017-11-15T10:01:16Z</dc:date>
  </entry>
</feed>
