<?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>Headless: How to filter by structure field?</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=120750959" />
  <subtitle>Headless: How to filter by structure field?</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=120750959</id>
  <updated>2026-04-07T05:55:33Z</updated>
  <dc:date>2026-04-07T05:55:33Z</dc:date>
  <entry>
    <title>RE: Headless: How to filter by structure field?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120752585" />
    <author>
      <name>Fernando Fernandez</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120752585</id>
    <updated>2021-05-04T13:18:29Z</updated>
    <published>2021-05-04T13:18:29Z</published>
    <summary type="html">&lt;p&gt;Thanks Javier, that was it! &lt;/p&gt;</summary>
    <dc:creator>Fernando Fernandez</dc:creator>
    <dc:date>2021-05-04T13:18:29Z</dc:date>
  </entry>
  <entry>
    <title>RE: RE: Headless: How to filter by structure field?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120751965" />
    <author>
      <name>Javier Gamarra</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120751965</id>
    <updated>2021-05-03T08:39:35Z</updated>
    <published>2021-05-03T08:39:35Z</published>
    <summary type="html">&lt;p&gt;The Date fields of the structure are just dates, without time
  information (dateModified/dateCreated those have time information and
  are indexed as datetime).&lt;/p&gt;
&lt;p&gt;So the filter should be like this: contentFields/DateReference le 2021-05-29&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-java"&gt;curl &amp;quot;http://localhost:8080/o/headless-delivery/v1.0/content-structures/58512/structured-contents?restrictFields=actions&amp;amp;filter=contentFields%2FDateReference%20le%202021-05-29&amp;quot; \
     -u 'test@liferay.com:test'&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;BUT if you are using 7.4 or 7.3, you could be affected by this &lt;a
    href="https://issues.liferay.com/browse/LPS-129637"&gt;bug&lt;/a&gt; (&lt;em&gt;Filter
    does not work for contentFields when content is upperCase, nor
    contains/startsWith in the new indexing&lt;/em&gt;). We are working on a
  fix but meanwhile if you are affected (you don't get any results
  back), you can enable the legacy indexer for DDM (no
  performance/results difference) and reindex, when it's fixed you can
  switch back.&lt;/p&gt;
&lt;p&gt;
  &lt;img src="/documents/14/0/Screenshot+2021-05-03+at+10.37.56.png/915f5892-0567-158d-83e3-b5b38f8b070a?t=1620031147495&amp;amp;imagePreview=1" /&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;br /&gt; &lt;/p&gt;</summary>
    <dc:creator>Javier Gamarra</dc:creator>
    <dc:date>2021-05-03T08:39:35Z</dc:date>
  </entry>
  <entry>
    <title>RE: RE: Headless: How to filter by structure field?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120753118" />
    <author>
      <name>Fernando Fernandez</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120753118</id>
    <updated>2021-05-02T14:25:09Z</updated>
    <published>2021-05-02T14:25:09Z</published>
    <summary type="html">&lt;p&gt;Thanks Javier. The error is now a differet one. &lt;/p&gt;
&lt;p&gt;I'm trying to select content based on date and, when I try with a
  syntax as per the mentioned article, an &amp;quot;&lt;strong&gt;Incompatible
  types&lt;/strong&gt;&amp;quot; 400 error is returned.&lt;/p&gt;
&lt;p&gt;The request is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;https://someserver/o/headless-delivery/v1.0/content-structures/182251/structured-contents?filter=contentFields/dateSchedule%20le%202018-02-13T12:33:12Z&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Also tried with single quotes, like %27, surrounding the date value.&lt;/p&gt;
&lt;p&gt;The field dateSchedule is an indexed ddm-date field in the structure.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Fernando&lt;/p&gt;</summary>
    <dc:creator>Fernando Fernandez</dc:creator>
    <dc:date>2021-05-02T14:25:09Z</dc:date>
  </entry>
  <entry>
    <title>RE: Headless: How to filter by structure field?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120752961" />
    <author>
      <name>Javier Gamarra</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120752961</id>
    <updated>2021-05-04T13:18:40Z</updated>
    <published>2021-05-02T09:50:11Z</published>
    <summary type="html">&lt;p&gt;Sorry for the documentation, we are in the process of improving it
  right now.&lt;/p&gt;
&lt;p&gt;The fields of the webcontent are inside the property
  &lt;em&gt;contentFields&lt;/em&gt;, so following OData syntax it should be
  something like:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-java"&gt;contentFields/property eq 'example'&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
  &lt;li&gt;Filtering mainly applies to fields indexed as keywords in Liferay
    DXP’s search&amp;quot; (why mainly?)&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;This is an Elasticsearch limitation/characteristic. Text
  indexed-fields are tokenized/transformed so they can not be used in
  sorting and several filtering operations. They are used in search
  because search does not do strict comparisons like 'eq' does. You can
  see a brief explanation &lt;a href="https://kb.objectrocket.com/elasticsearch/when-to-use-the-keyword-type-vs-text-datatype-in-elasticsearch#:~:text=The%20primary%20difference%20between%20the,fields%20are%20indexed%20as%20is."&gt;here&lt;/a&gt;.&lt;/p&gt;</summary>
    <dc:creator>Javier Gamarra</dc:creator>
    <dc:date>2021-05-02T09:50:11Z</dc:date>
  </entry>
  <entry>
    <title>Headless: How to filter by structure field?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120750958" />
    <author>
      <name>Fernando Fernandez</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120750958</id>
    <updated>2021-05-02T14:13:11Z</updated>
    <published>2021-05-01T17:12:31Z</published>
    <summary type="html">&lt;p&gt;Hi guys,&lt;/p&gt;
&lt;p&gt;DXP 7.2 in this case.&lt;/p&gt;
&lt;p&gt;I'm trying to filter a webcontent search with a structure field and
  failing. Maybe someone has done it before?&lt;/p&gt;
&lt;p&gt;I'm following &lt;a
    href="https://help.liferay.com/hc/en-us/articles/360031163631-Filter-Sort-and-Search"&gt;this
  article&lt;/a&gt; that briefly mentions filtering by a structure field,
  showing no example, and none of my attempts is working. I can filter
  by title, though.&lt;/p&gt;
&lt;p&gt;What works: filter=title eq 'SomeTitle'&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;https://servername/o/headless-delivery/v1.0/content-structures/182251/structured-contents?filter=title%20eq%20%27SomeTitle%27&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What doesn't work: filter=structFieldName eq 'SomeValue'&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;https://servername/o/headless-delivery/v1.0/content-structures/182251/structured-contents?filter=structFieldName%20eq%20%27SomeValue%27&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The answer, in these cases is:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-java"&gt;{
    &amp;quot;status&amp;quot;: &amp;quot;BAD_REQUEST&amp;quot;,
    &amp;quot;title&amp;quot;: &amp;quot;A property used in the filter criteria is not supported: structFieldName eq 'SomeValue'&amp;quot;
}

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Taking note of the article's paragraph saying &amp;quot;Filtering mainly
  applies to fields indexed as keywords in Liferay DXP’s search&amp;quot;
  (why mainly?), I checked and my failed examples are respecting this
  rule (indexed - keyword). Also tried with a Date field and got the
  same result.&lt;/p&gt;
&lt;p&gt;Any ideas?&lt;/p&gt;
&lt;p&gt;TIA&lt;/p&gt;
&lt;p&gt;Fernando&lt;/p&gt;</summary>
    <dc:creator>Fernando Fernandez</dc:creator>
    <dc:date>2021-05-01T17:12:31Z</dc:date>
  </entry>
</feed>
