1

I was using Sharepoint Rest api and the query looked like the one below

http://sitename/HR/_api/web/lists/GetByTitle('Employee')/Items?$top=4000&$filter=( substringof('100',Title) and substringof('ARISPL',Company) and substringof('HIBIS',House_x0020_Name))

Now I want to migrate to Search Api as querying against Note fields is not possible in Rest API

I was able to get items from the list with below query

http://sitename/HR/_api/search/query?querytext='Path:http://sitename/HR/Lists/Employee'

but I am not sure how to add filters against fields with Contains and a and condition

I tried the below query but it didnt work

http://sitename/HR/_api/search/query?querytext='Path:http://sitename/HR/Lists/Employee'&refinementfilters='AND((Department:mvrla)(Title:1000))'

Can someone help?

I want to convert the above rest api query to search api query

1

There is no contains filter

Search has different syntax

  • 1
    Danny, I think he's asking for contains in REST Search not the REST OData. – Matthew McDermott Mar 25 '17 at 12:25
  • Yes, link 3 and 4 point to Search Documentation, are they not correct? – Danny '365CSI' Engelman Mar 25 '17 at 12:28
  • The links are great. It was your statement that there is "no contains filter". Do you mean in REST? – Matthew McDermott Mar 26 '17 at 12:12
  • afaik, not in Search either, you can only have one wildcard in a searchstring(?) So you can't search for *msterda* – Danny '365CSI' Engelman Mar 27 '17 at 11:59
  • 1
    Nope, = is equals : is contains. itunity.com/article/… – Matthew McDermott Mar 28 '17 at 11:23
1

You should try out the SharePoint 2013 Search Query Tool. It will help you craft your query and show you the results.

You can use the colon as a contains operator :. In KQL AND is the default behavior between terms. I think your query would be something like: querytext='Path:http://sitename/HR/Lists/Employee/* Department:mvrla Title:1000' which should be the same as: querytext='Path:http://sitename/HR/Lists/Employee/* AND Department:mvrla AND Title:1000'

  • 1
    I interpreted 'contains' as a search where : *meth* returns something – Danny '365CSI' Engelman Mar 25 '17 at 12:31
0

The KQL query to use AND operation is as follows

<<siteurl>>/_api/search/query?querytext='Path:Path:http://sitename/HR/Lists/Employee (Department:mrvla) (Title:1000)'

You should enclose in double quote if you want exact match and space will treat as AND operation.

The above code blocks works as Path starts with given value and Department starts with mrvla and Title starts with 1000. There is no contains operation in a word.

Here is a MSDN article to know the keyword search options.

https://msdn.microsoft.com/en-us/library/office/ee558911.aspx

Thanks, Venkat Konjeti

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.