¿Por qué la cláusula where no funciona en sharepointsearch?

StringBuilder xmlString = new StringBuilder(
    "<QueryPacket xmlns='urn:Microsoft.Search.Query'>"
    + "<Query><SupportedFormats><Format revision='1'> urn:Microsoft.Search.Response.Document:Document"
    + "</Format></SupportedFormats><Context>"
    + " <QueryText language='en-US' type='FQL'>");

// this adds the search free form text 
    + "<Properties>"
    + "<Property name='Name'/>"
    + "<Property name='Department' />"
    + "<Property name='Property1' />"                
    + "<Property name='Property2' />"
    + "<Property name='Property3' />"
    + "<Property name='Property4' />"
    + "<Property name='Property5' />"
    + "</Properties>"
    + "<Where>"
    + "<IsNotNull><FieldRef Name='Name'></FieldRef></IsNotNull>"
    + "<And><IsNotNull><FieldRef Name='Property1'></FieldRef></IsNotNull></And>"
    + "</Where>"                                       
    + "</Query></QueryPacket>"


I am getting data with the null/empty value on Name and Property1 column. Why where is not working?

preguntado el 17 de mayo de 13 a las 08:05

3 Respuestas

It looks like your where clause is not properly formatted as @Damith suggested. Why dont you build your query using FAST Search for Sharepoint MOSS 2010 Query Tool. Its really quick and efficient way to work on this kind of tasks.

contestado el 17 de mayo de 13 a las 19:05

I downloaded this tool and able to get records but the issue is still exist. <IsNotNull><FieldRef Name='WireAuthorLastName' /></IsNotNull> also not working in filtering Null or empty data on WireAuthorLastName column. - Jeevan Bhatt

Is this property columns (property1, property2...etc) are crawled proeprties? did you do full crawl after adding it? - Prashant Lakhlani

No property1 and property2 was an example in my query (Just for explanation that IsNotNull is not working for any property).. I mean to say if if use <IsNotNull><FieldRef Name='WireAuthorLastName' /></IsNotNull> this will still returning data having blank/null in WireAuthorLastName column. - Jeevan Bhatt

as @john suggested in his answer, your KQL query is not proper. You need to build correct query. By using fast search tool you can build and execute queries and use them in your code. - Prashant Lakhlani

+ "<And><IsNotNull><FieldRef Name='Property1'></FieldRef>"+"</IsNotNull>And>"

In this line after IsNotNull Te estas perdiendo </ entonces la linea debe ser

+ "<And><IsNotNull><FieldRef Name='Property1'></FieldRef>"+"</IsNotNull></And>"

contestado el 17 de mayo de 13 a las 10:05

Your issue is that you've got the <and> clause sitting in the wrong place.

Debe tener un aspecto como este:

            <FieldRef Name='Name'>
             <FieldRef Name='Property1'></FieldRef>

It's a weird place to have to put the and clause, I know, but that's how CAML works. I strongly recommend using a program such as CAMLQueryHelper if you're going to use CAML instead of Linq.

contestado el 21 de mayo de 13 a las 20:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.