com.mongodb.MongoQueryException: Query failed with error code 2 and error message 'bad sort specification' on server localhost:27017]

Google Groups | srinivas seema | 4 months ago
  1. 1

    com.mongodb.MongoQueryException: Query failed with error code 2 and error message 'bad sort specification'

    Google Groups | 4 months ago | srinivas seema
    com.mongodb.MongoQueryException: Query failed with error code 2 and error message 'bad sort specification' on server localhost:27017]
  2. 0

    com.mongodb.MongoQueryException: Query failed with error code 2 and error message 'bad sort specification'

    Google Groups | 4 months ago | srinivas seema
    com.mongodb.MongoQueryException: Query failed with error code 2 and error message 'bad sort specification' on server localhost:27017]
  3. 0

    VersionOne Collector MongoDB Query Issue

    GitHub | 12 months ago | aniketvsawant
    org.springframework.data.mongodb.UncategorizedMongoDbException: Query failed with error code 17287 and error message 'Can't canonicalize query: BadValue unknown top level operator: $query' on server localhost:27017; nest
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Grails 3.1.6 with MongoDB 5.0.5-withDatabase with authentication does not work

    GitHub | 2 months ago | brittma
    com.mongodb.MongoQueryException: Query failed with error code 13 and error message 'not authorized for query on itemtest.item' on server testdb3:27017
  6. 0

    An object is annotated with {{@Document}} and {{@TextIndexed}} on several fields. The text index is created on the collection the right way. I assume it's done when the object is accessed the first time. However if the collection (or the database) is dropped, while the context is in place, the object is recreated but without the index. Consider the following code: {code:java} mongoTemplate.save(new ObjectSource()); mongoTemplate.find(new Query(new TextCriteria().matching("bla")), ObjectSource.class); mongoTemplate.dropCollection(ObjectSource.class); mongoTemplate.save(new ObjectSource()); mongoTemplate.find(new Query(new TextCriteria().matching("bla")), ObjectSource.class); {code} The first find works fine, the second find throws the exception below. This is easily reproducible and behaves the same whether the collection exists in the database prior to the run or not. {noformat} org.springframework.data.mongodb.UncategorizedMongoDbException: Query failed with error code 17007 and error message 'Unable to execute query: error processing query: ns=tenant1.objectSource limit=0 skip=0 Tree: TEXT : query=bla, language=, tag=NULL Sort: {} Proj: {} planner returned error: need exactly one text index for $text query' on server 127.0.0.1:27017; nested exception is com.mongodb.MongoQueryException: Query failed with error code 17007 and error message 'Unable to execute query: error processing query: ns=tenant1.objectSource limit=0 skip=0 Tree: TEXT : query=bla, language=, tag=NULL Sort: {} Proj: {} planner returned error: need exactly one text index for $text query' on server 127.0.0.1:27017 at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:101) at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2069) at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1912) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1723) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1706) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:602) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:593) at com.cisco.lockhart.model.springmongo.filter.SpringIssueTester.testSpringReproduceIssue(SpringIssueTester.java:34) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84) at org.testng.internal.MethodInvocationHelper$1.runTestMethod(MethodInvocationHelper.java:200) at org.springframework.test.context.testng.AbstractTestNGSpringContextTests.run(AbstractTestNGSpringContextTests.java:170) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:212) at org.testng.internal.Invoker.invokeMethod(Invoker.java:707) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:348) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305) at org.testng.SuiteRunner.run(SuiteRunner.java:254) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224) at org.testng.TestNG.runSuitesLocally(TestNG.java:1149) at org.testng.TestNG.run(TestNG.java:1057) at org.gradle.api.internal.tasks.testing.testng.TestNGTestClassProcessor.stop(TestNGTestClassProcessor.java:115) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:57) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) at com.sun.proxy.$Proxy2.stop(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:115) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:355) at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: com.mongodb.MongoQueryException: Query failed with error code 17007 and error message 'Unable to execute query: error processing query: ns=tenant1.objectSource limit=0 skip=0 Tree: TEXT : query=bla, language=, tag=NULL Sort: {} Proj: {} planner returned error: need exactly one text index for $text query' on server 127.0.0.1:27017 at com.mongodb.connection.ProtocolHelper.getQueryFailureException(ProtocolHelper.java:102) at com.mongodb.connection.QueryProtocol.execute(QueryProtocol.java:303) at com.mongodb.connection.QueryProtocol.execute(QueryProtocol.java:54) at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:159) at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:260) at com.mongodb.connection.DefaultServerConnection.query(DefaultServerConnection.java:183) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:397) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:394) at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:196) at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:169) at com.mongodb.operation.FindOperation.execute(FindOperation.java:394) at com.mongodb.operation.FindOperation.execute(FindOperation.java:57) at com.mongodb.Mongo.execute(Mongo.java:760) at com.mongodb.Mongo$2.execute(Mongo.java:747) at com.mongodb.DBCursor.initializeCursor(DBCursor.java:817) at com.mongodb.DBCursor.hasNext(DBCursor.java:151) at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1898) ... 56 more {noformat}

    Spring JIRA | 10 months ago | Doron Levari
    com.mongodb.MongoQueryException: Query failed with error code 17007 and error message 'Unable to execute query: error processing query: ns=tenant1.objectSource limit=0 skip=0 Tree: TEXT : query=bla, language=, tag=NULL Sort: {} Proj: {} planner returned error: need exactly one text index for $text query' on server 127.0.0.1:27017

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. com.mongodb.MongoQueryException

      Query failed with error code 2 and error message 'bad sort specification' on server localhost:27017

      at com.mongodb.operation.FindOperation$1.call()
    2. MongoDB Java Driver
      FindIterableImpl.forEach
      1. com.mongodb.operation.FindOperation$1.call(FindOperation.java:493)
      2. com.mongodb.operation.FindOperation$1.call(FindOperation.java:483)
      3. com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:241)
      4. com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:214)
      5. com.mongodb.operation.FindOperation.execute(FindOperation.java:483)
      6. com.mongodb.operation.FindOperation.execute(FindOperation.java:80)
      7. com.mongodb.Mongo.execute(Mongo.java:818)
      8. com.mongodb.Mongo$2.execute(Mongo.java:805)
      9. com.mongodb.OperationIterable.iterator(OperationIterable.java:47)
      10. com.mongodb.OperationIterable.forEach(OperationIterable.java:70)
      11. com.mongodb.FindIterableImpl.forEach(FindIterableImpl.java:158)
      11 frames
    3. com.nazara.ngdp
      ScheduleTableauJob.execute
      1. com.nazara.ngdp.TableauServiceHelper.MongoDataAccessor.readCollection(MongoDataAccessor.java:70)
      2. com.nazara.ngdp.TableauServiceHelper.ScheduleTableauJob.execute(ScheduleTableauJob.java:68)
      2 frames
    4. quartz
      SimpleThreadPool$WorkerThread.run
      1. org.quartz.core.JobRunShell.run(JobRunShell.java:202)
      2. org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
      2 frames