How to build lucene query with OR using search context?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2012 07:48 AM
In Search Context there is a method addAttributeQuery(QName qname, String value).
This creates search query with AND.
Is there any way I can add OR query in search context?
Suppose I have one property test1:name and another attribute test2:name.
I want to search name property with respect to test1:name as well as test2:name.
I can do it by writing lucene query and get the results. But I have to do it via Search Context.
Let me know if its possible as i do not see any method in SearchContext.java to take OR query.
This creates search query with AND.
Is there any way I can add OR query in search context?
Suppose I have one property test1:name and another attribute test2:name.
I want to search name property with respect to test1:name as well as test2:name.
I can do it by writing lucene query and get the results. But I have to do it via Search Context.
Let me know if its possible as i do not see any method in SearchContext.java to take OR query.
Labels:
- Labels:
-
Archive
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2012 09:05 AM
You need to use the SearchParameter object and SearchService if you are using JAVA.
Also for javascript you need to user the SearchService.
Also for javascript you need to user the SearchService.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2012 09:26 AM
Can you be bit more clear how can I use it in Search Context?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2012 07:40 AM
In Search Context there is a method addAttributeQuery(QName qname, String value).
This creates search query with AND.
Is there any way I can add OR query in search context?
Suppose I have one property test1:name and another attribute test2:name.
I want to search name property with respect to test1:name as well as test2:name.
I can do it by writing lucene query and get the results. But I have to do it via Search Context.
Let me know if its possible as i do not see any method in SearchContext.java to take OR query.
Anyone has any idea??
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2012 07:56 AM
Hi,
look here for info about SearchService http://docs.alfresco.com/4.0/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Fconcepts%2Frm-searchsy...
You can define a query using SearchService.LANGUAGE_FTS_ALFRESCO and a template as descibed here http://docs.alfresco.com/4.0/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Fconcepts%2Frm-searchsy...
Regards,
Andrea
look here for info about SearchService http://docs.alfresco.com/4.0/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Fconcepts%2Frm-searchsy...
You can define a query using SearchService.LANGUAGE_FTS_ALFRESCO and a template as descibed here http://docs.alfresco.com/4.0/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Fconcepts%2Frm-searchsy...
Regards,
Andrea
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2012 10:07 AM
Thanks Andrea.
I want information on SearchContext as it has already been used and I cannot change it at this point of time.
I want to know whether we can add OR query using SearchContext.
I want information on SearchContext as it has already been used and I cannot change it at this point of time.
I want to know whether we can add OR query using SearchContext.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2013 09:11 AM
'OR' condition is being called by default unless 'AND' condition is being called by force.
Check the svn code for SearchContext object at http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/web-client/source/jav...
/**
* @return Returns if AND is forced between text terms. False (OR terms) is the default.
*/
public boolean getForceAndTerms()
{
return this.forceAndTerms;
}
Check the svn code for SearchContext object at http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/web-client/source/jav...
/**
* @return Returns if AND is forced between text terms. False (OR terms) is the default.
*/
public boolean getForceAndTerms()
{
return this.forceAndTerms;
}
