Delen via


FullTextSqlQuery with QueryText length greater than 4096 characters throws ArgumentOutOfRange exception.

The max number of characters that can be passed through FullTextSqlQuery is 4096 characters, beyond this length throws an exception ArgumentOutOfRangeException. You will get the same behavior when using the webservice QueryEx(XmlNode) as well.

    1: private void ExecQuery()
    2: {
    3: ResultTableCollection resultCollection = null;
    4: SPSite site = new SPSite("https://server/");
    5: FullTextSqlQuery fullText = new FullTextSqlQuery(site);
    6: fullText.ResultTypes = ResultType.RelevantResults;
    7: fullText.QueryText = "SELECT Title, Path, Description, Write, Rank, Size FROM Scope()"; //max 4096
    8: fullText.KeywordInclusion =KeywordInclusion.AnyKeyword;
    9: resultCollection = fullText.Execute();
   10: ResultTable results = resultCollection[ResultType.RelevantResults];
   11: dataGridView1.DataSource = null;
   12: if (results.RowCount > 0)
   13: {
   14: DataTable dtresults = new DataTable();
   15: dtresults.TableName = "Result"
   16: dtresults.Load(results, LoadOption.OverwriteChanges);
   17: DataSet ds = new DataSet("All_Results");
   18: ds.Tables.Add(dtresults);
   19: dataGridView1.DataSource = ds;
   20: dataGridView1.DataMember = "Result";
   21: }
   22: }

Hope this helps.

Comments

  1. Something u are forgot: if u using SPSite u must dispose this object. Something like that. using (SPSite site = new SPSite(...)) { }
  2. Did u fulltextsearch at SPList scope? pls answer me, if it possble. yafos(at)yandex(dot)ru
  • Anonymous
    June 15, 2009
    I was working on case, where Customer wanted to have the length of the QueryText property of FullTextSqlQuery