0

I can see the document list can be searched by matching a value of document properties. But I need to search document list which has a specific word in their content. How can I achieve this by oData.svc query?

Is it possible using Lucene Index concept? If yes then how?

Updated

I am working with Sense/Net 6.3.0.6337 Community Version.

I have tried to achieve it by following query

https://example.com/OData.svc/workspaces/Document/abcd_gmail_com/Document_Library/?metadata=no&$select=*&query=Taruna

It is working for .docx and .txt files only but doesn't work for .xml and .pdf file.

Is it sensenet version issue?

Thanks

1 Answers1

1

You can add a query string argument called "query" to each and every GET request, e.g. http://www.example.com/OData.svc/?$select=Name,Index,Icon&query=about
returns content that contain "about" from the whole requested site

You can find more examples here in the Custom Query Options section

Lajos Gallay
  • 1,169
  • 7
  • 16
  • I have tried that but not getting success `https://example.com/OData.svc/workspaces/Document/abcd_gmail_com/Document_Library/?metadata=no&$select=*&query=this` – Ankitkumar Tandel Mar 28 '18 at 10:19
  • @AnkitkumarTandel You don't have to add '$select=*', you get all the fields and values without using the select param. On the second hand have you checked the users permissions on the document that contains the word that you are searching for? Can the user open the file? What type of file is it, is it a word document or pdf? – Aniko Litvanyi Mar 29 '18 at 07:36
  • @AnikoLitvanyi yes user's own created document and it is an xml (.xml) document – Ankitkumar Tandel Mar 29 '18 at 08:41
  • Checking your example query it turned out, that the term 'this' is the part of the [stop word dictionary](http://wiki.sensenet.com/Field_Indexing#Stop-word_dictionary) – Aniko Litvanyi Mar 29 '18 at 09:57
  • I have tried different words also. I can see it is only working for .docx, .doc and .txt files not for .xml and .pdf files. Is it right behaviour? – Ankitkumar Tandel Mar 29 '18 at 10:14
  • According to [this article](http://wiki.sensenet.com/Text_extractors#Built-in_text_extractors) it should work for .xml and .pdf files too. I checked both of them and it worked for me with .pdf files with no problem, but I was unable to search in .xml files. Maybe there's a bug related to .xml files. I've filed an [issue about this on github](https://github.com/SenseNet/sensenet/issues/322) – Aniko Litvanyi Mar 29 '18 at 10:58
  • @AnikoLitvanyi I am using sensenet v6.3. Might it be not working because of low version? – Ankitkumar Tandel Mar 30 '18 at 04:40
  • @AnkitkumarTandel unfortunately it does not work in the current version either – Aniko Litvanyi Apr 03 '18 at 09:10
  • @AnikoLitvanyi It is working for .docx, .doc, .pdf and .xml files by Sensenet version 6.5.4.10440, please check below query for admin login on https://demo.sensenet.com `https://demo.sensenet.com/OData.svc/workspaces/Document/Document%20workspace%20with%20space/Document_Library?query=Dubbang` – Ankitkumar Tandel Apr 03 '18 at 09:28
  • @AnikoLitvanyi I have taken the file from below link https://msdn.microsoft.com/en-us/library/ms762271(v=vs.85).aspx How it is not .xml file ? can you elaborate more for this? – Ankitkumar Tandel Apr 03 '18 at 09:36
  • @AnkitkumarTandel I've checked in the actual version (v7.1) with your .xml file and it works. Did you used the same file when you've tested it in v6.3? – Aniko Litvanyi Apr 03 '18 at 09:38
  • No, it was a different file, let me check once – Ankitkumar Tandel Apr 03 '18 at 09:39
  • @AnikoLitvanyi I am unable to upload the .xml file on v6.3. It is giving `400 Invalid file being uploaded` error. – Ankitkumar Tandel Apr 03 '18 at 10:32
  • Thanks AnikoLitvanyi & LajosGallay The issue was in my code. Some how it was not indexing my xml docs. Other than it is working with above query. – Ankitkumar Tandel Apr 12 '18 at 13:06