Sharepoint search all columns of a list - sharepoint

I have a list in sharepoint. I want to search across all the columns for a term. How would you co about doing this?
My idea was to get the SPFieldCollection, get all the fields and generate the CAML on the fly then query the list to get the items. Just wondering if there was a better way to do this as generating the CAML may prove to be difficult.

If you don't like the idea of building the CAML using string concatenation, then you could consider using CAML.Net

I'm accessing SP with webservices, not Object Model. Anyway, I would create the CAML dynamically. Generating the CAML will not be difficult, as you can always tryout your logic with
U2U CAML Query Builder http://www.u2u.net/res/Tools/CamlQueryBuilder.aspx

Related

SharePoint 2010, CAML query to see if a new item has been added to a list (Announcements)

all. I am trying to build a CAML query for a SP2010 list that will check the Announcements to see if anything new has been added (or a CAML query + some functionality). I do not truly understand CAML and SP yet and would be grateful for any help - thank you.
Have a look around an SPQuery object if you want to go down the CAML route.
You will want to get all the items for a given date/time range unless you have a field that flags if an item is new..... the link below should help you build a query
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/fed59f8e-72e2-46e2-9329-460fd65d7536/caml-query-datetime
Once you have a SPQuery object pass it to the SPList GetItems() method
You will then have a collection of items what you do with them then is all up to you :)
Hope this helps

How to get data from a caml results using caml

The scene is:
I've got items using caml on a list view(e.g. previewlist), and I'll have to query again from these items, is it possible using caml to query from SPListItemsCollection? as MSSQL we can do select * from(select * from tablename), but how can we finished that in caml ?
And if that impossible, i'll have to search from those items first and then add the result to a splist or a spview, anybody knows how to do this? (yeah, two diff ideas).
Maybe you can try using SourceQuery property, retrieve original query and build new one using operator to combine two queries?

Dynamically building CAML query in SharePoint 2010

I have an requirement of get the items from the list depends on the ItemID.I have list which contains 5000 items in which I retrieve only 1000 items for that I will dynamically build the CAML query using JohnHoliday CAML.NET and the query have 1000 conditions at that time I got Value does not fall within the Expected Range error. The query works fine upto 150 items but it throws error when the ItemID increases.Could you provide a suitable workaround for this issue ?
You're running into the size limit for CAML queries, which AFAIK isn't documented anywhere, but definitly exists.
If you only need to support 2010 then you can use the new <In> operator which probably with get you a bid further
In sharepoint 2010 there is a List view threshold configuration that give the administrator the ability to determine the maximum items you can retreive in a one patch
and to overcome this problem you can use
ContentIterator
check this link for more help
Why not iterate over SPList.Items and take which items you need? So there's no need to build a complex caml query. Or call SPList.GetItemByUniqueId.

Query and/or Search for SharePoint Document ID

We have the sharepoint 2010 environment with Document ID's enabled.
Given (part of) a Doc ID, we want to programmatically retrieve the document(s) matching that ID. The problem seems to be that this column is rather special, in that it might need special handling.
Using an SPSiteDataQuery, fetching the _dlc_DocId field as part of the viewfields works fine. However, including it as part of the where query never results in any documents being fetched.
Using the Search API has gotten us nowhere at all.
Has anyone pulled this off, or any suggestions on how to tackle this problem?
[Update] Turns out we were fooled by subtle errors in the XML and bad debugging misinterpretations. This stuff just works fine.
I don't normally contribute to these sorts of things because cleverer people than I always get there before me, but as this is an old one with no proper answer I think I'll add my thoughts for those who find this page.
I was struggling with this but after a little digging around and learning a bit of Caml I got this working.
I am using the SharePoint Client Object Model against SharePoint 2010 and Office365 beta.
Start off your query by looking at the all list items query:
Microsoft.SharePoint.Client.CamlQuery.CreateAllItemsQuery().ViewXml
"<View Scope=\"RecursiveAll\">\r\n <Query>\r\n </Query>\r\n</View>"
Stick a where child inside the query
Then add in
<Eq><FieldRef Name="_dlc_DocId" /><Value Type="Text">MDXC2KE55ASN-3-80</Value></Eq>
replacing MDXC2KE55ASN-3-80 with the doc ID you are looking for inside the where.
Also don't forget you might want to make use of these too:
<ViewFields><FieldRef Name="_dlc_DocId" /></ViewFields>
<RowLimit>1</RowLimit>
Then use List.GetItems() method to bring back the ListItemCollection.
Just in case nobody comes with a slick solutions from the depths of the Sharepoint infrastructure:
What would Google Do?
Slice is, Dice it and dump it in a reverse index.
Solr and Lucene offer supreme tools for this. The idea is to cut the DocId's in small pieces and add the location of the document to the bucket for that piece.
Say We have "A real nice document" with Id ABCD123. You would add it to the buckets
ABCD, BCD1, CD12, D123
When searching for a partial ID (+ other data like dates, types, ...) you (well the search engine) creates the union of the buckets + applies additonal constraints.
To make this happen you need to write a spider for the sharepoint server and a routine which makes a record of data elements to be indexed.
Put a nice REST interface in frnt of it (actually SOLR already has that), integrate it in the main sharepoint server, and nobody needs to know there is something else running behind it.
These products can also incrementally update the indexes, so they can be kept up to date.
you could use the following to get the Document ID.
SPFile file = MethodToUploadFileToServer(web, filepath);
SPListItem item = file.Item;
string DocID = item.Properties["_dlc_DocId"].ToString();

CAML Query Help?

Is there a way to get all versions of list item(s) using a CAML Query?
I don't think that's exposed directly in any of the APIs that take CAML queries as parameters. You'll probably need to get the current version of the ListItem using your CAML query and then make another call to get all versions of that item.

Resources