First of all, collecting large results using "Hits" object is too slow since it re-executes the search internally when you need more than 100 hits. It is better to use the "HitCollector".
Second, Why don't you return an array of a custom object and let the WebServer make the serialization for you. Like; [Serializable] public class MyClass { public string RecipeID; public string RecipeTitle; ..... } [WebMethod] Public MyClass[] GetMyClasses() { MyClass[] myclasses = new MyClass[resultCount]; for(int i=0 ; i<resultCount ; i++){ myclasses[i] = new MyClass(); myclasses[i].RecipeID = .... myclasses[i].RecipeTitle = .... ..... } return myclasses; } DIGY -----Original Message----- From: Scott Remiger [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 12, 2008 6:47 PM To: lucene-net-user@incubator.apache.org Subject: Convert Hits to XML We are currently converting the hits to a dataset then onto an XML document which seems inefficient Can someone suggest a better way of doing this? The web service will time out when we get to about 36 thousands hits we want to get the web service wide open(not limit the number of records to return); Hits _oRecipeHits = _oLuceneIndexSearch.ExecuteSearch(_bqQuery, INDEXPATH); DataTable _dtSearchResults = new DataTable(); _dtSearchResults.Columns.Add("RecipeID", typeof(string)); _dtSearchResults.Columns.Add("RecipeTitle", typeof(string)); _dtSearchResults.Columns.Add("Ingredients", typeof(string)); _dtSearchResults.Columns.Add("Course", typeof(string)); _dtSearchResults.Columns.Add("Equipment", typeof(string)); _dtSearchResults.Columns.Add("Holiday", typeof(string)); _dtSearchResults.Columns.Add("CookTime", typeof(string)); _dtSearchResults.Columns.Add("SkillLevel", typeof(string)); _dtSearchResults.Columns.Add("RecipeRating", typeof(string)); _dtSearchResults.Columns.Add("IsPublic", typeof(bool)); _dtSearchResults.Columns.Add("relevance", typeof(float)); if (_oRecipeHits.Length() > 0) { for (int iResultsCount = 0; iResultsCount < _oRecipeHits.Length(); iResultsCount++) { Document _dResultsDoc = _oRecipeHits.Doc(iResultsCount); DataRow _rRecipe = _dtSearchResults.NewRow(); _rRecipe["RecipeID"] = _dResultsDoc.Get("RecipeID"); _rRecipe["RecipeTitle"] = _dResultsDoc.Get("RecipeTitle"); _rRecipe["RecipeDescription"] = _dResultsDoc.Get("RecipeDescription"); _rRecipe["Ingredients"] = _dResultsDoc.Get("Ingredients"); _rRecipe["Course"] = _dResultsDoc.Get("Course"); _rRecipe["Equipment"] = _dResultsDoc.Get("Equipment"); _rRecipe["Holiday"] = _dResultsDoc.Get("Holiday"); _rRecipe["CookTime"] = _dResultsDoc.Get("CookTime"); _rRecipe["SkillLevel"] = _dResultsDoc.Get("SkillLevel"); _rRecipe["Region"] = _dResultsDoc.Get("Region"); _rRecipe["RecipeRating"] = _dResultsDoc.Get("RecipeRating"); _rRecipe["IsPublic"] = LUCENE_BOOL_TRUE.Equals(_dResultsDoc.Get("IsPublic")); _rRecipe["relevance"] = _oRecipeHits.Score(iResultsCount); _dtSearchResults.Rows.Add(_rRecipe); } } Scott Remiger 888 Lumber Exchange Building 10 South Fifth Street Minneapolis, MN 55402 O: 612.238.4951 F: 612.746.4237