There is an interesting comment at the bottom of the Jguru site.   Does anyone 
know the answer?

The comment:
"Why delete/query is Y but query/delete is N?"

________________________________________
From: Ben Martz [[email protected]]
Sent: Thursday, November 11, 2010 10:13 AM
To: [email protected]
Subject: Re: Lucene.Net Stress Error

I haven't been able to find a comprehensive list of thread-safe methods on the 
web although this matrix (http://www.jguru.com/faq/view.jsp?EID=913302) may be 
useful. The only object that is consistently called out as NOT thread-safe is 
QueryParser.

Section 11.2, "Threads and concurrency, in the second edition of Lucene in 
Action (http://www.manning.com/hatcher3/) may be of interest to you. I 
generally recommend that anyone getting started with Lucene on any platform 
should read this very useful book since it answers most common questions about 
using Lucene.

http://wiki.apache.org/lucene-java/LuceneFAQ#Is_the_QueryParser_thread-safe.3F
http://wiki.apache.org/lucene-java/LuceneFAQ#Is_the_IndexSearcher_thread-safe.3F
http://plusplus.wordpress.com/2007/07/26/starting-lucene/

I hope this helps.

Cheers,
Ben

Moray McConnachie wrote:
> Does anyone know of a guide somewhere summarising what is safe to reuse
> between threads and what is not?
> Thanks,
> Moray
> -------------------------------------
> Moray McConnachie
> Director of IT    +44 1865 261 600
> Oxford Analytica  http://www.oxan.com
>
> -----Original Message-----
> From: biarada com [mailto:[email protected]]
> Sent: 09 November 2010 21:41
> To: [email protected]
> Subject: Re: Lucene.Net Stress Error
>
> I think you are right.  BiaradaCacheManager.GetSiteProductQueryParser();
> is static class. I convert it to dynamic version. I will see the result
> in an hour.
> Thanks,
>
>
> 2010/11/8 Ben Martz<[email protected]>
>
>> Is your code written in a thread-safe manner? I am immediately
>> suspicious when I see something like:
>>
>> QueryParser parser = BiaradaCacheManager.GetSiteProductQueryParser();
>>
>> What type of functionality are your various BiaradaCacheManager
>> methods providing in terms of object reuse?
>>
>> Just an idea since I've done extensive multi-thread stress testing on
>> my product and never encountered such an issue.
>>
>> Cheers,
>> Ben
>>
>>
>> biarada com wrote:
>>
>>> 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;
>>>          }
>>>
>>>
>
> ---------------------------------------------------------
> Disclaimer
>
> This message and any attachments are confidential and/or privileged. If this 
> has been sent to you in error, please do not use, retain or disclose them, 
> and contact the sender as soon as possible.
>
> Oxford Analytica Ltd
> Registered in England: No. 1196703
> 5 Alfred Street, Oxford
> United Kingdom, OX1 4EH
> ---------------------------------------------------------
>

Reply via email to