cancel
Showing results for 
Search instead for 
Did you mean: 

How does xPath search work?

mrinal3199
Champ in-the-making
Champ in-the-making
Hi,

   Can any one explain me how does xpath search works in node browser?

Thanks,
Mrinal 
7 REPLIES 7

jpotts
World-Class Innovator
World-Class Innovator
Have you already read the documentation? For example:
http://docs.alfresco.com/4.1/references/API-JS-xpathSearch.html

If you have and you still have questions, please provide specifics.

Jeff

mrinal3199
Champ in-the-making
Champ in-the-making
I am trying this in Javascript as follows:

var query = "/app:company_home/st:sites/cm:siteName/cm:documentLibrary/cm:FolderName/*[@cm:name='Content Name']";
var nodes = search.xpathSearch(query);

But this function search.xpathSearch(query) seem to be not working fine. Am i doing any wrong here? So, i tried in node browser also but i am not getting anything. So, do hep me plz.

Thanks,
Mrinal

mrinal3199
Champ in-the-making
Champ in-the-making
Hi Sanket,

   Thanks for replying…I had already done through lucene search but my requirement is different. Lucene is full text search and i want an exact term search. Means if i am searching for "Test", i should get noderef of contents having content field value equal to "Test" only not like "Test A*". SO, can you help me writing correct syntax for xpath or any other way to get the exact term search results.

Thanks,
Mrinal

kaynezhang
World-Class Innovator
World-Class Innovator
Lucene is more than what you called full text search.
You can search for a single term,for an exact term,for fields,for ranges and so on.
for example if you  search nodes under company home  and count property is 12, and cm:title field contains "test":

+PATH:"/app:company_home//*"
+@cm\:title:"test"
+@cm\:count:12

jpotts
World-Class Innovator
World-Class Innovator
The trick to an exact match search is that the property cannot be tokenized. This is controlled by the content model XML. Most fields are tokenized, ie, broken into tokens to facilitate searching within the field value. If a property is not tokenized you can do an exact match search against it. If you want to do an exact match against an out-of-the-box property that is tokenized you'll have to create a custom property that is not tokenized and use something like a behavior to keep the properties in sync.

Jeff

mrinal3199
Champ in-the-making
Champ in-the-making
Yeah actually everywhere i am ended up with this option only atlast for this.
Thanks jeff, It was really helpfull. I got it.

Thanks,
Mrinal