cancel
Showing results for 
Search instead for 
Did you mean: 

fts-alfresco search multi value property

raaftjon
Champ on-the-rise
Champ on-the-rise
hello
I have a own alfresco model type with a multi value property like this:


  <type name="test:document">
    <title>Test Dokument</title>
    <description>Ein test Dokument</description>
    <parent>cm:content</parent>
    <property name="test:values">
      <type>d:int</type>
      <mandatory>false</mandatory>
      <multiple>true</multiple>
      <index enabled="false"></index>
    </property>
  </type>


It's possible to create a fts-alfresco search query for this multi value property?
e.g.

The Requirements are to search all test:document with a test:values of 1, 2 or 5.
<javascript>
var def = {
  query: 'TYPE:"test:document" and @test:values:[1,2,5]',
  language: 'fts-alfresco'
};
var nodes = search.query(def);
</javascript>

Kind regards,
Jonas Schmid
3 REPLIES 3

mitpatoliya
Star Collaborator
Star Collaborator
I think you need to change language as "lucene"

I have also test with lucene. But the queries doesn't work:
<javascript>
  query: 'TYPE:"test:document" and @test\\:values:[1,2,5]'
  query: 'TYPE:"test:document" and @test\\:valuesSmiley Sad1 2 5)' // lucene field grouping
  query: 'TYPE:"test:document" and @test\\:valuesSmiley Sad in (1,2,5))' // like sql
  query: 'TYPE:"test:document" and @test\\:values:1 and @test\\:values:2 and @test\\:values:5',
</javascript>

A other approach is the useing of a simple text field (d:text) and store all int values comma separated into the text field:
e.g. 'v2v,v3v,v5v'

then I can call the following query:
<javascript>
  query: 'TYPE:"test:document" and @test\\:textFieldValuesSmiley Sad"*v2v*" "*v3v*" "*v5v*")'
</javascript>

This is not pretty, but it works! Has everybody a idee, how to use multi value property in a query?

avyaznikov
Champ in-the-making
Champ in-the-making
Use disjunction:

var arrayOfValues = [1, 2, 5];
var query = "";
for (var i in arrayOfValues) {
  if (i > 0) {
    query += " OR ";
  }
  query += "@test:values:" + arrayOfValues;
}

The resulting string is
<blockcode>@test:values:1 OR @test:values:2 OR @test:values:5</blockcode>

*if you are using lucene - escape colon with backsplashes