2

I was trying to mimic a search site via listdata.svc due to the incapability of OOTB Search Result webpart.

Is there'a way to utilize KQL or any other way to allow users to search for a sentence?

Here's my code:

var webServerRelativeUrl = _spPageContextInfo.webServerRelativeUrl;
$.ajax({
    url: webServerRelativeUrl + "/_vti_bin/listdata.svc/Pages?$filter=(Title eq 'keyword')",
    method: "GET",
    headers: { "Accept": "application/json; odata=verbose" },
    success: function (response) {
        console.log(response.d.results[0].Title);
    },
    error: function (data) {
        console(JSON.stringify(response));
    }
});

However, users won't be able to get any results if they search for more than a word. Is there any syntax reference can help? Or there's a better way than "/_vti_bin/listdata.svc" ?

1 Answer 1

2

The SP2010 Search API is not exposed in the REST endpoints or in the javascript CSOM but you can get to it via SPServices. Take a look at this blog post, it should give you what you need:

http://www.itidea.nl/index.php/example-of-using-the-spservices-search-web-service/

The search results come back in XML so you'll need to do some XML traversal in your code to pull out the title of the document/page/listItem in your searchResults.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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