IFullTextQuery - exception if there are too may ob

2019-08-26 13:38发布

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条回答
姐就是有狂的资本
2楼-- · 2019-08-26 14:07

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.

查看更多
登录 后发表回答