Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Let's assume that enterprise and fast search are not an option. Are CAML queries (with CONTAINS operator) a proper way to do a full text search in fields of a publishing page? Or is that for any reason not recommendable?

The approach would be something like:
String query = "<Where><Contains><FieldRef Name="Title" /><Value Type=""Text"">searchText</Value></Contains></Where>";
PublishingPageCollection pages = publishingWeb.GetPublishingPages(query);

share|improve this question
    
What other way is there? ;) Seems perfectly acceptable to me. –  James Love Nov 29 '11 at 9:17
    
Another way could be, to fetch all publishing pages and filter the pages in code (add only matching pages to result list). But that only if something speaks against CAML –  HutzelGutzel Nov 29 '11 at 9:59
2  
CAML is fed directly to the COM objects which call stored procedures in the DB, trying to filter the pages in code is nowhere near as efficient is that. –  James Love Nov 29 '11 at 10:18
    
OK convinced! That possiblity was only a fallback if something had spoke against CAML. Thanks. –  HutzelGutzel Nov 29 '11 at 12:54

1 Answer 1

up vote 1 down vote accepted

When executing CAML queries, the number of results returned will be determined by the throttle settings. The default throttle limit is 5000.

One more interesting point against CAML if you use indexed fields : SharePoint 2010 CAML Query fails when indexed columns used ( I am not sure if this problem is real)

Having said that, If you need results as PublishingPage objects ( I see you use publishingWeb.GetPublishingPages(query)), CAML is the only good way to do that.

share|improve this answer
    
Like I said in the comment there, I've never had an issue using CAML against indexed fields, and I'm certain I've seen the SP object model query against indexed fields, also... –  James Love Nov 29 '11 at 14:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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