Hi,
I am using lucene for my site, however in these days my site get very
popular. when request amount get 10 or above in a second, some case (I dont
know when it is happenig ) the lucene parser get the following error. But
when I try to execute lucene again it works fine. could you help me why it
happens.
Regards,

Yilmaz Saridemir.
Error:

Cannot parse '(lcd tv) AND HasExpired:0  AND SortByPrice:{0000000 TO
0084699}': Encountered " ")" ") "" at line 1, column 11.
Was expecting one of:
    <EOF>
    <AND> ...
    <OR> ...
    <NOT> ...
    "+" ...
    "-" ...
    "(" ...
    "*" ...
    "^" ...
    <QUOTED> ...
    <TERM> ...
    <FUZZY_SLOP> ...
    <PREFIXTERM> ...
    <WILDTERM> ...
    "[" ...
    "{" ...
    <NUMBER> ...





My code :

        public SearchResponseInfoWcf SearchWcf(int productId)
        {
            SearchResponseInfoWcf info = new SearchResponseInfoWcf();
            try
            {
                MultiSearcher allSearcher =
BiaradaCacheManager.GetAllMultiSearcher();
                QueryParser parser =
BiaradaCacheManager.GetSiteProductQueryParser();
                Query query = parser.Parse(productId.ToString());
                TopDocs docs = allSearcher.Search(query, 1);
                if (docs.scoreDocs.Length > 0)
                {
                    Dictionary<int, ProductInfoWcf> products = new
Dictionary<int, ProductInfoWcf>();
                    Document doc = allSearcher.Doc(docs.scoreDocs[0].doc);
                    ProductInfoWcf p = LoadProductInfo(products, doc,
docs.scoreDocs[0].score);
                    BiaradaDataManager.FillProductInfoData(products,
productId.ToString());
                    info.ProductIdInfo = p;
                    string[] matchs = GetMatchedProducts(doc);
                    if (matchs.Length > 0)
                    {
                        if (matchs[0] != "" || matchs.Length > 1)
                        {
                            BooleanQuery matchedAllQuery = new
BooleanQuery();
                            for (int i = 0; i < matchs.Length; i++)
                            {

                                if (matchs[i].Length > 0)
                                {
                                    Query matchedQuery = new
WildcardQuery(new Term("MatcheId", "*," + matchs[i] + ",*"));  //#1
                                    matchedAllQuery.Add(matchedQuery,
BooleanClause.Occur.SHOULD);
                                }
                            }
                            //Query hasExpiredQuery = new WildcardQuery(new
Term("HasExpired", "0"));  //#1
                            //matchedAllQuery.Add(hasExpiredQuery,
BooleanClause.Occur.MUST);
                            //Query matchedQuery = parser.Parse( "(" +
sb.ToString() + ") AND HasExpired:0 ");
                            BooleanQuery filterBoolenQuery = new
BooleanQuery();
                            filterBoolenQuery.Add(new TermQuery(new
Term("HasExpired", "0")), BooleanClause.Occur.MUST);
                            filterBoolenQuery.Add(new TermQuery(new
Term("SortByPrice", WcfConfigManager.MinPrice)),
BooleanClause.Occur.MUST_NOT);
                            Filter filter = new
QueryWrapperFilter(filterBoolenQuery);

                            Sort matchSort = new
Sort(GetSortField(SortingTypes.PriceAsc));
                            //Console.WriteLine(DateTime.Now.Millisecond);
                            MultiSearcher searcher =
BiaradaCacheManager.GetMultiSearcher();
                            TopDocs matchedDocs =
searcher.Search(matchedAllQuery, filter,
ConfigManager.MaxMatchedProductCount, matchSort);
                            //Console.WriteLine(DateTime.Now.Millisecond);
                            StringBuilder sbMatched = new StringBuilder();
                            sbMatched.Append("0");
                            for (int i = 0; i < matchedDocs.totalHits && i <
ConfigManager.MaxMatchedProductCount; i++)
                            {
                                Document docMatched =
searcher.Doc(matchedDocs.scoreDocs[i].doc);
                                ProductInfoWcf pMatched =
LoadProductInfo(info.ReletedInfos, docMatched,
matchedDocs.scoreDocs[i].score);
                                sbMatched.Append(",");
                                sbMatched.Append(pMatched.ProductId);
                            }

BiaradaDataManager.FillProductInfoData(info.ReletedInfos,
sbMatched.ToString());
                        }
                    }
                }
            }
            catch (Exception _e)
            {

            }
            int hasError = 0;
            if (info.SearchInfos == null)
            {
                info.SearchInfos = new Dictionary<int, ProductInfoWcf>();
                hasError = 1;
            }
            if (info.AdvInfos == null)
            {
                info.AdvInfos = new Dictionary<int, ProductInfoWcf>();
                hasError += 2;
            }
            if (info.ProductIdInfo== null)
            {
                info.ProductIdInfo = new ProductInfoWcf();
                hasError += 4;
            }
            else if (info.ProductIdInfo.Name == null)
            {
                info.ProductIdInfo.Name  = "biarada";
                hasError += 8;
            }
            if (info.ReletedInfos== null)
            {
                info.ReletedInfos = new Dictionary<int, ProductInfoWcf>();
                hasError += 16;
            }
            if (hasError > 0)
            {

            }

            return info;
        }

Reply via email to