<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Can I apply a template for each word on a phrase? in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/can-i-apply-a-template-for-each-word-on-a-phrase/m-p/84508#M25750</link>
    <description>&lt;DIV&gt;&lt;SPAN&gt;I am using Alfresco Rest API (&lt;/SPAN&gt;&lt;SPAN&gt;/alfresco/api/-default-/public/search/versions/1/search&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;I perform the following search:&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;{
    "query": {
        "query": "WOOF:((H) (A minor) (Anor))"
    },
    "defaults": {
        "defaultFTSOperator": "AND",
        "defaultFTSFieldOperator": "OR"
    },
    "templates": [
        {
            "name": "WOOF",
            "template": "(%content OR %cm:title) AND TYPE:content"
        }
    ]
}&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;And I get like 200 results, but if I search the same:&amp;nbsp; (H) (A minor) (Anor) in Alfresco Share ,I get about 500 results. I found that it does something like this:&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;{
    "query": {
        "query": "((WOOF:(H)) (WOOF:(A minor)) (WOOF:(Anor)))"
    },
    "defaults": {
        "defaultFTSOperator": "AND",
        "defaultFTSFieldOperator": "OR"
    },
    "templates": [
        {
            "name": "WOOF",
            "template": "(%cm:content OR %cm:title) AND TYPE:content"
        }
    ]
}&lt;/PRE&gt;&lt;DIV&gt;(Note: I know that Alfresco Shares uses&amp;nbsp;&lt;SPAN&gt;an internal API&lt;/SPAN&gt;&lt;SPAN&gt;/slingshot and that's why there are variations, so I am trying to kind of duplicate its behavior).&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;So, the previous query gives me the results that I am looking for, but to accomplish that, I had to add the WOOF template as prefix of each term.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;Is there a way to achieve this without adding the template per term?&amp;nbsp;because the user its just going to type: (H) (A minor) (Anor)&amp;nbsp; and what I expect, is&amp;nbsp;the outcome of this last query.&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Sat, 18 Apr 2020 01:41:36 GMT</pubDate>
    <dc:creator>DI_SI_GO</dc:creator>
    <dc:date>2020-04-18T01:41:36Z</dc:date>
    <item>
      <title>Can I apply a template for each word on a phrase?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/can-i-apply-a-template-for-each-word-on-a-phrase/m-p/84508#M25750</link>
      <description>&lt;DIV&gt;&lt;SPAN&gt;I am using Alfresco Rest API (&lt;/SPAN&gt;&lt;SPAN&gt;/alfresco/api/-default-/public/search/versions/1/search&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;I perform the following search:&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;{
    "query": {
        "query": "WOOF:((H) (A minor) (Anor))"
    },
    "defaults": {
        "defaultFTSOperator": "AND",
        "defaultFTSFieldOperator": "OR"
    },
    "templates": [
        {
            "name": "WOOF",
            "template": "(%content OR %cm:title) AND TYPE:content"
        }
    ]
}&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;And I get like 200 results, but if I search the same:&amp;nbsp; (H) (A minor) (Anor) in Alfresco Share ,I get about 500 results. I found that it does something like this:&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;{
    "query": {
        "query": "((WOOF:(H)) (WOOF:(A minor)) (WOOF:(Anor)))"
    },
    "defaults": {
        "defaultFTSOperator": "AND",
        "defaultFTSFieldOperator": "OR"
    },
    "templates": [
        {
            "name": "WOOF",
            "template": "(%cm:content OR %cm:title) AND TYPE:content"
        }
    ]
}&lt;/PRE&gt;&lt;DIV&gt;(Note: I know that Alfresco Shares uses&amp;nbsp;&lt;SPAN&gt;an internal API&lt;/SPAN&gt;&lt;SPAN&gt;/slingshot and that's why there are variations, so I am trying to kind of duplicate its behavior).&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;So, the previous query gives me the results that I am looking for, but to accomplish that, I had to add the WOOF template as prefix of each term.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;Is there a way to achieve this without adding the template per term?&amp;nbsp;because the user its just going to type: (H) (A minor) (Anor)&amp;nbsp; and what I expect, is&amp;nbsp;the outcome of this last query.&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 18 Apr 2020 01:41:36 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/can-i-apply-a-template-for-each-word-on-a-phrase/m-p/84508#M25750</guid>
      <dc:creator>DI_SI_GO</dc:creator>
      <dc:date>2020-04-18T01:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: Can I apply a template for each word on a phrase?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/can-i-apply-a-template-for-each-word-on-a-phrase/m-p/84509#M25751</link>
      <description>&lt;P&gt;Before going into the question of the template: The use of parantheses to group query inputs is extremely weird. I don't know if the search would really be executed in a way that a user would expect.&lt;/P&gt;
&lt;PRE&gt;WOOF:((H) (A minor) (Anor))&lt;/PRE&gt;
&lt;P&gt;=&amp;gt; Given your default FTS operator + field operator config, this would effectively search for&lt;/P&gt;
&lt;PRE&gt;WOOF:H OR WOOF:A OR WOOF:minor OR WOOF:Anor&lt;/PRE&gt;
&lt;P&gt;=&amp;gt; where I would expect the user that rather intends to find what the following query would return&lt;/P&gt;
&lt;PRE&gt;WOOF:H OR WOOF:"A minor" OR WOOF:Anor&lt;/PRE&gt;

&lt;P&gt;As for the template: The thing is that templates are applied before field term groupings are expanded. So&lt;/P&gt;
&lt;PRE&gt;WOOF:(A B)&lt;/PRE&gt;
&lt;P&gt;becomes&lt;/P&gt;
&lt;PRE&gt;(cm:content:(A B) OR cm:title:(A B)) AND TYPE:content&lt;/PRE&gt;
&lt;P&gt;What is happening in Share is that - I assume - someone has customised it to apply WOOF as the default field name when no field name is explicitly set, and as a result, the input (A B) would be turned into&lt;/P&gt;
&lt;PRE&gt;(WOOF:A WOOF:B)&lt;/PRE&gt;
&lt;P&gt;You should be able to achieve the same with ReST API by specifying the defaultFieldName property with the value of WOOF in the search request JSON.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Apr 2020 16:56:49 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/can-i-apply-a-template-for-each-word-on-a-phrase/m-p/84509#M25751</guid>
      <dc:creator>afaust</dc:creator>
      <dc:date>2020-04-18T16:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: Can I apply a template for each word on a phrase?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/can-i-apply-a-template-for-each-word-on-a-phrase/m-p/84510#M25752</link>
      <description>&lt;P&gt;Thanks, yes that was what I was looking for.&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Apr 2020 21:09:40 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/can-i-apply-a-template-for-each-word-on-a-phrase/m-p/84510#M25752</guid>
      <dc:creator>DI_SI_GO</dc:creator>
      <dc:date>2020-04-19T21:09:40Z</dc:date>
    </item>
  </channel>
</rss>

