12-29-2016 05:39 AM
I'm using Alfresco Community Edition 5.2 (EA). I'm building a separate front-end for the users to search for documents, and am using the REST APIs to communicate with Alfresco.
I've noticed that the results returned via the REST API (Post > Search) match with the results shown for the same query in the node browser. However, these differ from results shown when searching within Alfresco.
e.g. If I search Alfresco for 'term', I will get documents which contain 'term' across all properties, including name, content and tags. However, if I enter the same query in node browser, or in the API, I only get documents which contain 'term' in their content. Documents which have 'term' in both the title and as tags, but not in the content, are not returned.
Further, the ordering of results returned by the API differs from the order shown in Alfresco, even when sorted by relevance or score.
The query I attempted via the REST API:
{
"query": {
"query": "TERM",
"language": "afts"
},
"spellcheck":{"query":"TERM"},"sort": [{"type":"FIELD", "field":"relevance", "ascending":"false"}]
}
I could at least include documents with 'term' in their name by updating the query to:
{
"query": {
"query": "@cm:name:TERM OR TERM"...
However, this still did not consider document tags.
I simply want to ensure that the results which are shown when searching in Alfresco are the same results which are fetched and displayed via API.
12-29-2016 06:48 AM
The Alfresco Share Faceted Search UI uses a special (internal) ReST backend to execute queries that transparently enhances the user search terms, i.e. it adds filters to exclude results that make no sense in the Share application, adds a query template to apply the keywords (temrs) on multiple fields at the same time (i.e. name, title, description, content, tags ...), and also prepares the results in a way that they can be consumed by the UI with as little overhead as possible.
The public ReST API for queries is a raw interface to the search APIs and as such you would have to replicate a lot of the intrinsic conditionals the backend for the UI applies. Unfortunately the v1 ReST API documentation is still missing for 5.2 so it is hard to tell what parameters you'd have to set how at this time. The documentation should be there sometime in February at the latest when Alfresco One 5.2 is scheduled to be released.
01-10-2017 01:44 PM
Hi
It is possible to boost terms relative to each other.
It is currently not possible via a template, which is a known issue.
title:woof^4 OR description:woof
There are other biases from the normal lucene scoring for each term and how many ORs match.
Andy
01-05-2017 11:20 AM
Axel Faust is correct, the v1 search API is a low level API, to reproduce the results from Share you'll have to match the query it executes. Fortunately, we've tried to help in that area by providing some "pre-canned" queries. One of the other new v1 REST APIs for 5.2 is /queries/nodes, the query behind this endpoint matches what Share (the v0 API) uses and should therefore give you the same results.
We do have some reference documentation available for the new APIs in the form of the API Explorer. You can grab the latest API Explorer WAR from here and apply it to your local install as shown in my first blog post. To get information on the low level search API choose "Search API" from the drop down in the header.
Hope that helps!
01-05-2017 11:01 PM
Thanks Gavin.
Surprisingly, I've found that GET .../queries/nodes returns results in order of modified date, by default. We are also not able to specify an 'order by' of relevance/score. Is there an update that we are likely to be missing or are we using it wrong?
01-05-2017 12:26 PM
@Sanket, if you're using latest Community 5.2 release (201612 GA, 201611 EA or even 201609 EA) then another option might be to try the pre-configured query (which uses a pre-configured query template), for example:
GET .../queries/nodes?term=TERM
BTW: all of the new 5.2 REST APIs are documented via the API explorer: GitHub - Alfresco/rest-api-explorer at 5.2.0
Here's a quick snapshot view of the Queries API: Swagger UI
Please note the description "... The search term is used to look for nodes that match against name, title, description, full text content or tags. ...".
For more general background on the new 5.2 REST APIs, please also see: Alfresco 5.2 REST APIs
Regards,
Jan
01-05-2017 11:01 PM
Thanks Jan,
I will copy-paste my reply to Gavin above:
Surprisingly, I've found that GET .../queries/nodes returns results in order of modified date, by default. We are also not able to specify an 'order by' of relevance/score. Is there an update that we are likely to be missing or are we using it wrong?
01-06-2017 04:45 AM
Sanket Baxi, hmm, yes, you're right, that does appear to be an oversight on our part, I have raised a story on our backlog to cover that scenario, thanks very much for your feedback.
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.