cancel
Showing results for 
Search instead for 
Did you mean: 

Modifying search query for Full Text Search

jeyaa
Champ in-the-making
Champ in-the-making
Hi all,

Alfresco search will search also the contents and I have a constraint that the search should not search and get the details if the search text is a XML tag.

For instance If I have a xml called Sample.xml,

<sample-xml>
      ABCDEFGH
</sample-xml>

If I enter the text "sample-xml", it should not retrieve Sample.xml.  Is it possible to modify Alfresco's search query if so please lemme know how to pursue. If I cant proceed in this way, please suggest me the best approach to find the solution.,
11 REPLIES 11

andy
Champ on-the-rise
Champ on-the-rise
Hi

If you mean "I do not want to find the tages <sample.xml> in the content of my XML file", then this is down to your converter from xml to text.
I believe the default is to strip out tags ??

Andy

jeyaa
Champ in-the-making
Champ in-the-making
Thanks for your reply andy. I would be grateful if you'd explain me in detail about your solution.


Regards,
Jeya

amitabhandari1
Champ in-the-making
Champ in-the-making
Hi Jeya,

I am not sure if this would help you   but I can mention query which helps to filter some specific text :
In the below example you will not be able to search content having text as "fox"
For e.g. - the Lucene query you can check in nodebrowser

+(TEXT:*) -(TEXT:fox)

Here "+" will be considered as "must match "
"-"   as "must not match"

Now if you want to apply this when you are searching from search box  then you have  to make change at API level.
SearchContext is the class which is basically used for building query . You can check buildQuery() method.

Thanks,

jeyaa
Champ in-the-making
Champ in-the-making
Thanks for the reply amita. This would be really helpful to me. Smiley Happy


Regards,
Jeya

jeyaa
Champ in-the-making
Champ in-the-making
Hi Amita,

Lucene search is not considering "<" and ">" characters. Do you have any idea about that.

Eg :

try.xml
<sample>lucene</sample>


If I try with
@cm\:name:"try*" +TEXT:"lucene" 
@cm\:name:"try*" +TEXT:"<lucene>"

Both query is resulting me ""try.xml", since the text "lucene" is not inside tags. Why the search is behaving like this.? Any Idea?

amitabhandari1
Champ in-the-making
Champ in-the-making
Did  you try directly with  this code:

TEXT:<sample>lucene</sample>

Thanks,

jeyaa
Champ in-the-making
Champ in-the-making
No amita, I have a xml named try.xml and there it has the content <sample>lucene</sample>

I had written the query as

@cm\:name:"try*" +TEXT:"<lucene>"

I also tried with the query u added now, it too gives the same result amita.

amitabhandari1
Champ in-the-making
Champ in-the-making
Hi Jeya,

I am not getting what search result you want .
If you want to exclude use  -
If you want to  get the content with that text then use +

Clarify your requirement.

Thanks,

jeyaa
Champ in-the-making
Champ in-the-making
Let me explain you clearly amita.

I want to search the content of a file (ie., try.xml in my example) which is not an xml element. So from my above example, If I search by the text "sample", the search result should be '0'. So I want to exclude the text which is present inside the tags.

So I did a sample search query, just to test whether lucene is considering "<" abd ">" characters in its search or not. So i have written 2 queries

@cm\:name:"try*" +TEXT:"lucene"
@cm\:name:"try*" +TEXT:"<lucene>"

In which both the queries returned the same result. So from this we can say that lucene is not considering "<" and ">" in its search. I had an idea of writing query like this,


@cm\:name:"try*" -TEXT:"<*>"  +TEXT:"sample"

ie., eliminating the content which is inside the xml tags. But from the above conclusion those tags(<>) will not be considered.

So how could I pursue to eliminate the xml elements from searching?



Regards,
jeya