Я работаю над функцией, которая основана на сортировке значения запроса функции.Solr сортировать по значению функции запрос не работает
Функция запроса, как показано ниже:
функцияhttp://localhost:8983/solr/collection/select?q=*:*&sort=if(exists(f1_t), f1_t, theme)+ASC&wt=json&indent=true
Рода является «if(exists(f1_t), f1_t, theme) ASC
»
Поэтому в основном то, что я делаю, если поле «f1_t
» (который представляет собой динамическое поле типа TextField) существует, тогда сортировка основана на значении поля иначе сортировка основана на значении «темы», которое также является текстовым полем (но это не динамическое поле).
Но когда я запускаю это, с ниже исключения. Я попробовал функцию «if» с целыми значениями, и он отлично работает. Мне было просто интересно, можете ли вы помочь мне понять, почему запрос функции выше не удается? Как я могу заставить это работать?
Solr версии я использую 4.6.1
"trace": "java.lang.UnsupportedOperationException\n\tat
org.apache.lucene.queries.function.FunctionValues.doubleVal(FunctionValues.java:47)\n\tat
org.apache.lucene.queries.function.valuesource.IfFunction$1.doubleVal(IfFunction.java:83)\n\tat
org.apache.lucene.queries.function.ValueSource$ValueSourceComparator.copy(ValueSource.java:152)\n\tat
org.apache.lucene.search.TopFieldCollector$OneComparatorNonScoringCollector.collect(TopFieldCollector.java:86)\n\tat
org.apache.lucene.search.Scorer.score(Scorer.java:65)\n\tat
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:621)\n\tat
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:297)\n\tat
org.apache.solr.search.SolrIndexSearcher.getDocListNC(SolrIndexSearcher.java:1529)\n\tat
org.apache.solr.search.SolrIndexSearcher.getDocListC(SolrIndexSearcher.java:1395)\n\tat
org.apache.solr.search.SolrIndexSearcher.search(SolrIndexSearcher.java:474)\n\tat
org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:438)\n\tat
org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:208)\n\tat
org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)\n\tat org.apache.solr.core.SolrCore.execute(SolrCore.java:1859)\n\tat
org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:723)\n\tat
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:419)\n\tat
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:203)\n\tat
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)\n\tat
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)\n\tat
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)\n\tat
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)\n\tat
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)\n\tat
org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)\n\tat
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)\n\tat
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)\n\tat
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)\n\tat
org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)\n\tat
org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)\n\tat
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)\n\tat org.eclipse.jetty.server.Server.handle(Server.java:368)\n\tat
org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)\n\tat
org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)\n\tat
org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:942)\n\tat
org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1004)\n\tat
org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640)\n\tat
org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)\n\tat
org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)\n\tat
org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)\n\tat
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)\n\tat
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)\n\tat java.lang.Thread.run(Thread.java:662)\n",
"code": 500
Сортировки TextFields не будет работать, как вы ожидаете, если Поле - ключевое слово. Используйте StrField для сортировки, если это возможно. – MatsLindh
Я могу изменить их на StrField, но можно ли добиться этой функции сортировки с помощью StrField? Я попробовал StrField и получил то же исключение – Bourne
ваш вопрос связан с [this] (http://stackoverflow.com/questions/40307145/apache-solr-sort-by-one-of-fields-with-condition/40312415) Вопрос. То, как сортировка в настоящее время построена в lucene, не позволяет использовать ничего, кроме двухместных для поиска. Именно по этой причине функция сортировки 'if (exists (firstname), firstname, lastname) asc' не может работать, а solr возвращает' UnsupportedOperationException' в 'FunctionValues # doubleVal (int)' метод. –