IFullTextQuery - exception if there are too may objects

怎甘沉沦 提交于 2019-12-13 05:00:07

问题


This code works fine:

Query query = parser.Parse(expression);

IFullTextSession session = Search.CreateFullTextSession(this.Session);

IFullTextQuery fullTextQuery = session.CreateFullTextQuery(query, new[] { typeof(MappedSequence) });

var l1 = fullTextQuery.List();

as long as the query does not return too many objects. If the query contains too many objects the generated sql code is too long and sql server throws an exception. One working solution is to obtain all objects using paging which is fairly slow. Is there a better solution?

Thanks.

C


回答1:


If I remember correctly, fullTextQuery.List() does a big

select ... where ID_COL IN ( id1, id2, id3, id4 ... )

where id1, id2 ... are parameters, which number is limited in SQL Server. This way, you get NHibernate entities from lucene documents. Long story short, there is no workaround, except paging.

You can use page size of 1000 elements, if you REALLY need to get this much of data.

Getting 1000's of entities would be slow somewhere : when you display them on screen, for exemple.



来源:https://stackoverflow.com/questions/5339696/ifulltextquery-exception-if-there-are-too-may-objects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!