Alfresco: Unable to search via Lucene by date - lucene

I am writing an Alfresco webscript to search for content by date, and not having any luck.
My query looks like this:
PATH:\"/app:company_home/st:sites/cm:mysite/cm:documentLibrary/cm:News/*\"
AND #cm\\:created:[2013-09-25T00:00:00.000Z TO NOW]
I have three folders in my News folder:
Folder 1, created on 2013-09-24
Folder 2, created on 2013-09-24
Folder 3, created on 2013-09-25 <- Created a day after the other two.
My Lucene search is always returning 3 items. Why does it return three items when the first two were created before the 25th?
And why do I have to search with a range to get any results? Why does this not work when Alfresco's documentation says that truncated datetime formats are supported?
PATH:\"/app:company_home/st:sites/cm:mysite/cm:documentLibrary/cm:News/*\"
AND #cm\\:created:"2013-09-25"
Alfresco version: 3.3
EDIT:
I have checked that the following lines exist in alfresco/model/dataTypeAnalyzers.properties:
d_dictionary.datatype.d_date.analyzer=org.alfresco.repo.search.impl.lucene.analysis.DateAnalyser
# d_dictionary.datatype.d_datetime.analyzer=org.alfresco.repo.search.impl.lucene.analysis.DateAnalyser
d_dictionary.datatype.d_datetime.analyzer=org.alfresco.repo.search.impl.lucene.analysis.DateTimeAnalyser

A working example from version 3.x in a freemarker template
<#assign startPunt = companyhome.childrenByLuceneSearch["TYPE:\"wn:zaak\" AND #wn\\:vernietigingsdatum:[MIN TO "+date?string("yyyy-MM-dd'T'HH:mm:ss")+"] "]>

Related

SQL/BigQuery on github samples

I'm using the google bigquery tool, I'm trying to select ALL sample github repositories that have a pom.xml file and within the content of the file, have an artifact id ex-ex e.g
<artifactId>ex-ex</artifactId>
For this I have broken it down into 2 steps:
1) Find all pom.xml files
SELECT sample_repo_name FROM 'bigquery-public-data.github_repos.sample_contents' WHERE sample_path LIKE 'pom.xml'
2) Select the repositories which contain ex-ex artifact (in the content table)
AND content LIKE '%ex-ex'
The 2nd part of the query does not work (no results found) and is likely due to some syntax error somewhere. Full query below:
SELECT sample_repo_name FROM 'bigquery-public-data.github_repos.sample_contents' WHERE sample_path LIKE 'pom.xml' AND content LIKE '%ex-ex' LIMIT 1000
Would really appreciate help with this, thanks!
Have you tried '%ex-ex%'? Without the second %, you are only searching for records whose last 5 characters are 'ex-ex'. Adding content to the select in your first query and spot checking a few results, the content field appears to be XML (pom.xml, duh) and seem to end with </project>, and thus will probably never match with '%ex-ex'.

Alfresco FTS - why first digit of folder's name should be escaped?

I have a question regarding the alfresco FTS/lucene search. It is known that in the search query some special characters have to be escaped, like space (by _x0020_).
But it turned out that if folder's name first chatacter is a digit, it should also be escaped. It can be easily tested in Node Browser by creating a folder, like 123456 and navigate to the parent folder in node browser (in my case I have following folder structure: */2017/123456/):
Primary Path: /app:company_home/st:sites/<some-folders>/cm:_x0032_017/cm:_x0031_23456
^this is 2 ^ and this is 1
If I don't ecape first character of the folder I have 500 error returned.
Why is that, I tried to find something relevant in Alfresco documentation, but didn't manage to.
Alfresco v.4.2.0
Lucene search uses ISO 9075 codification (SQL) like similar frameworks, so we need to encode the path elements. It would be nice if the API hides this requirement like the browser url but you could use ISO9075Encode to do the job.

Alfresco lucene search cannot find folder

I have a folder in document library of a site. I want to find all content of that folder. Running following lucene/alfresco-fts query in Node Browser returns No items found:
PATH:"/app:company_home/st:sites/cm:mysite/cm:documentLibrary/cm:MyFolder/*"
Which is wrong, as I have documents in that folder and running same query for different folder returns proper result. Another strange thing is that I cannot get this folder: following query also returns No items found:
PATH:"/app:company_home/st:sites/cm:mysite/cm:documentLibrary/cm:MyFolder"
Also if I get content of document library then MyFolder is skipped in the results and subfolder is returned:
PATH:"/app:company_home/st:sites/cm:mysite/cm:documentLibrary/*"
Name | Parent
--------------|---------------------
cm:MyFolder2 | /app:company_home/st:sites/cm:mysite/cm:documentLibrary
cm:MySubfolder| /app:company_home/st:sites/cm:mysite/cm:documentLibrary/cm:MyFolder
I have checked the aspects and properties of MyFolder and they are the same as MyFolder2. I do not have any custom behaviours/rules/etc.
How can I make first lucene query work and return content of MyFolder?
Try updating metadata on the folder so Solr re-indexes it. You could also get its db id and then tell solr to re-index it by db id. If it has over 1000 children, a FTS query may fail. - Known issue. Try using a txmd query.
I would suggest you to get the node ref of the folder from folder details page and search in node browser. There you can get the primary path. Please cross verify the path you use to search using lucene or use that primary path to search for the folder in lucene search.
Another possibility is that the locale property(sys:locale) of the folder(MyFolder) will be different from the locale of your browser. Please check whether the locale of MyFolder and the other folders for which result is shown, are same or not. If not that can also be a reason.

SharePoint REST API getFolderByServerRelativeUrl Returns Nothing

I would like to drill into the library and then into a specified folder, but I am having problems getting 'getFolderByServerRelativeUrl' to grab anything for me.
This http://_base/_api/web/getFolderByServerRelativeUrl('LibName')/files returns zero results. But if I use http://_base/_api/web/lists/getbytitle('LibName')/items it returns multiple items.
/_api/web/lists/getbytitle('<list title>')/items endpoint returns all list items within a library, /_api/web/getFolderByServerRelativeUrl('<url>')/files returns only files located under (one level beneath only) the specified folder.
Example
Assume the following Documents library structure:
Documents (library)
|
Guides (folder)
|
SharePoint User Guide.docx (file)
Then, the following request:
/_api/web/lists/getbytitle('Documents')/items will return 2 items:
list item associated with Guides folder
list item associated with file
At the same time, the request: /_api/web/getFolderByServerRelativeUrl('Documents')/files
will returns 0 files since there are no files contained in the root folder
but the request with provided folder url:
/_api/web/getFolderByServerRelativeUrl('Documents/Guides')/files
will return SharePoint User Guide.docx file.
You're using the wrong URL. Try appending it to the other URL.

SharePoint 2010 - Use FilterMultiValue in combination with documentSet (to filter document library)

Has anybody used the FilterMultiValue in combination with DocumentSet?
I have a list with 2 content types (1 = document and 2 = document set).
I have added 4 documents: 2 documents and 2 document sets.
There is a column om my list (DWHID) that I want to use to filter the list. 1 document and 1 document set are linked to dwhid 5436. the other document and documentset are linked to dwhid 1234.
Now when I do this filter (?FilterField1=DWHID&FilterValue1=5436), everything works fine:
I get 1 document and 1 document set, as expected. The same for ?FilterField1=DWHID&FilterValue1=1234.
But when I use this filter (?FilterName=DWHID&FilterMultiValue=5436), the documents are filtered correctly but I see all the documentsets (the one linked to 5436 AND the one linked to 1234).
Any idea how to solve this? Or is it a bug?
Thx in advance!