org.hibernate.search.exception.SearchException: HSEARCH000232: The specified query 'id:{1 TO 3}' contains a numeric sub query which targets the string encoded field(s) 'id'. Check your query or try limiting the targeted entities.

Hibernate JIRA | Sanne Grinovero | 1 year ago
  1. 0

    The Query Validation is not allowing a Numeric RangeQuery on an id field even if it's being encoded as a {{@NumericField}} {noformat}org.hibernate.search.exception.SearchException: HSEARCH000232: The specified query 'id:{1 TO 3}' contains a numeric sub query which targets the string encoded field(s) 'id'. Check your query or try limiting the targeted entities. at org.hibernate.search.query.engine.impl.LazyQueryState.validateQuery(LazyQueryState.java:154) at org.hibernate.search.query.engine.impl.LazyQueryState.search(LazyQueryState.java:98) at org.hibernate.search.query.engine.impl.QueryHits.updateTopDocs(QueryHits.java:250) at org.hibernate.search.query.engine.impl.QueryHits.<init>(QueryHits.java:145) at org.hibernate.search.query.engine.impl.QueryHits.<init>(QueryHits.java:114) at org.hibernate.search.query.engine.impl.HSQueryImpl.getQueryHits(HSQueryImpl.java:452) at org.hibernate.search.query.engine.impl.HSQueryImpl.queryEntityInfos(HSQueryImpl.java:268) at org.hibernate.search.test.id.NumericIdEncodingTest.expectedProjections(NumericIdEncodingTest.java:62) {noformat} {code}@Indexed public class Staff { @DocumentId @NumericField final Long id; @Field(store = Store.YES) final String name; Staff(long id, String name) { this.id = id; this.name = name; } } {code}

    Hibernate JIRA | 1 year ago | Sanne Grinovero
    org.hibernate.search.exception.SearchException: HSEARCH000232: The specified query 'id:{1 TO 3}' contains a numeric sub query which targets the string encoded field(s) 'id'. Check your query or try limiting the targeted entities.
  2. 0

    The Query Validation is not allowing a Numeric RangeQuery on an id field even if it's being encoded as a {{@NumericField}} {noformat}org.hibernate.search.exception.SearchException: HSEARCH000232: The specified query 'id:{1 TO 3}' contains a numeric sub query which targets the string encoded field(s) 'id'. Check your query or try limiting the targeted entities. at org.hibernate.search.query.engine.impl.LazyQueryState.validateQuery(LazyQueryState.java:154) at org.hibernate.search.query.engine.impl.LazyQueryState.search(LazyQueryState.java:98) at org.hibernate.search.query.engine.impl.QueryHits.updateTopDocs(QueryHits.java:250) at org.hibernate.search.query.engine.impl.QueryHits.<init>(QueryHits.java:145) at org.hibernate.search.query.engine.impl.QueryHits.<init>(QueryHits.java:114) at org.hibernate.search.query.engine.impl.HSQueryImpl.getQueryHits(HSQueryImpl.java:452) at org.hibernate.search.query.engine.impl.HSQueryImpl.queryEntityInfos(HSQueryImpl.java:268) at org.hibernate.search.test.id.NumericIdEncodingTest.expectedProjections(NumericIdEncodingTest.java:62) {noformat} {code}@Indexed public class Staff { @DocumentId @NumericField final Long id; @Field(store = Store.YES) final String name; Staff(long id, String name) { this.id = id; this.name = name; } } {code}

    Hibernate JIRA | 1 year ago | Sanne Grinovero
    org.hibernate.search.exception.SearchException: HSEARCH000232: The specified query 'id:{1 TO 3}' contains a numeric sub query which targets the string encoded field(s) 'id'. Check your query or try limiting the targeted entities.
  3. 0

    Hibernate Search 5.0 Numeric Lucene Query HSEARCH000233 issue

    Stack Overflow | 2 years ago | adam
    org.hibernate.search.exception.SearchException: HSEARCH000233: The specified query '+(value:1 text:test)' contains a string based sub query which targets the numeric encoded field(s) 'value'. Check your query or try limiting the targeted entities.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Hibernte-Search: 'Can't build query for type x.y.z.EntityA' which is neither indexed nor has any indexed sub-types

    Stack Overflow | 2 days ago | rose1
    org.hibernate.search.exception.SearchException: HSEARCH000278: Can't build query for type x.y.z.A.EntityA' which is neither indexed nor has any indexed sub-types.
  6. 0

    Hi, From what I heard, from Hibernate Search 5 on, adding a @SortableField annotation is required to perform any kind of sort on a field. This seems to apply to id fields too, since I get warnings in the logs if I don't. Unfortunately, putting an @SortableField on an @Id/@DocumentId will make Hibernate Search initialization explode when an entity (say Level2) is referenced from another (say Level1) as an @IndexedEmbedded: when parsing annotations for Level1, the engine will find the @SortableField on the id field of Level2, but will not find the id field on Level2 ( ?). And crash, with this kind of error : {noformat} org.hibernate.search.exception.SearchException: HSEARCH000299: @SortableField declared on org.hibernate.search.test.embedded.sortablefield.Level2SortableId#id references to undeclared field 'level2Child.id' at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.bindSortableFieldAnnotation(AnnotationMetadataProvider.java:810) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.checkForSortableField(AnnotationMetadataProvider.java:1353) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeMemberLevelAnnotations(AnnotationMetadataProvider.java:853) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeClass(AnnotationMetadataProvider.java:469) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.checkForIndexedEmbedded(AnnotationMetadataProvider.java:1584) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeMemberLevelAnnotations(AnnotationMetadataProvider.java:857) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeClass(AnnotationMetadataProvider.java:469) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.getTypeMetadataFor(AnnotationMetadataProvider.java:130) at org.hibernate.search.spi.SearchIntegratorBuilder.initDocumentBuilders(SearchIntegratorBuilder.java:373) at org.hibernate.search.spi.SearchIntegratorBuilder.buildNewSearchFactory(SearchIntegratorBuilder.java:199) at org.hibernate.search.spi.SearchIntegratorBuilder.buildSearchIntegrator(SearchIntegratorBuilder.java:117) at org.hibernate.search.hcore.impl.HibernateSearchSessionFactoryObserver.sessionFactoryCreated(HibernateSearchSessionFactoryObserver.java:75) at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:35) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:541) at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444) at org.hibernate.search.test.DefaultTestResourceManager.buildSessionFactory(DefaultTestResourceManager.java:108) at org.hibernate.search.test.DefaultTestResourceManager.openSessionFactory(DefaultTestResourceManager.java:76) at org.hibernate.search.test.SearchTestBase.setUp(SearchTestBase.java:42) 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:497) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.hibernate.testing.junit4.FailureExpectedHandler.evaluate(FailureExpectedHandler.java:41) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.hibernate.testing.junit4.BeforeClassCallbackHandler.evaluate(BeforeClassCallbackHandler.java:26) at org.hibernate.testing.junit4.AfterClassCallbackHandler.evaluate(AfterClassCallbackHandler.java:25) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) {noformat} Adding an @Field annotation on Level2.id will not solve the issue, since it will crash another way (seems forbidden to add a field named exactly like the @Id field). {noformat} org.hibernate.search.exception.SearchException: HSEARCH000247: An indexed field defined on 'org.hibernate.search.test.embedded.sortablefield.Level2SortableId:id' tries to override the id field settings. The document id field settings cannot be modified. Use a different field name. at org.hibernate.search.engine.metadata.impl.TypeMetadata$Builder.addProperty(TypeMetadata.java:469) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeMemberLevelAnnotations(AnnotationMetadataProvider.java:872) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeClass(AnnotationMetadataProvider.java:469) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.getTypeMetadataFor(AnnotationMetadataProvider.java:130) at org.hibernate.search.spi.SearchIntegratorBuilder.initDocumentBuilders(SearchIntegratorBuilder.java:373) at org.hibernate.search.spi.SearchIntegratorBuilder.buildNewSearchFactory(SearchIntegratorBuilder.java:199) at org.hibernate.search.spi.SearchIntegratorBuilder.buildSearchIntegrator(SearchIntegratorBuilder.java:117) at org.hibernate.search.hcore.impl.HibernateSearchSessionFactoryObserver.sessionFactoryCreated(HibernateSearchSessionFactoryObserver.java:75) at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:35) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:541) at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444) at org.hibernate.search.test.DefaultTestResourceManager.buildSessionFactory(DefaultTestResourceManager.java:108) at org.hibernate.search.test.DefaultTestResourceManager.openSessionFactory(DefaultTestResourceManager.java:76) at org.hibernate.search.test.SearchTestBase.setUp(SearchTestBase.java:42) 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:497) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.hibernate.testing.junit4.FailureExpectedHandler.evaluate(FailureExpectedHandler.java:41) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.hibernate.testing.junit4.BeforeClassCallbackHandler.evaluate(BeforeClassCallbackHandler.java:26) at org.hibernate.testing.junit4.AfterClassCallbackHandler.evaluate(AfterClassCallbackHandler.java:25) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) {noformat} Note that : * this is tied to indexing entities: when there is no @Id annotation on the "id" attribute, I can freely define an @Field on the "id" attribute, and everything works fine. * this will happen regardless of whether the id field is part of the @IndexedEmbedded or not. I see two workarounds at the moment: * refraining from adding the @SortField annotation (this works, after all) * defining a separate @Field (named "idSort", for instance) just for sorting

    Hibernate JIRA | 12 months ago | Yoann Rodière
    org.hibernate.search.exception.SearchException: HSEARCH000247: An indexed field defined on 'org.hibernate.search.test.embedded.sortablefield.Level2SortableId:id' tries to override the id field settings. The document id field settings cannot be modified. Use a different field name.

    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. org.hibernate.search.exception.SearchException

      HSEARCH000232: The specified query 'id:{1 TO 3}' contains a numeric sub query which targets the string encoded field(s) 'id'. Check your query or try limiting the targeted entities.

      at org.hibernate.search.query.engine.impl.LazyQueryState.validateQuery()
    2. Hibernate Search Engine
      HSQueryImpl.queryEntityInfos
      1. org.hibernate.search.query.engine.impl.LazyQueryState.validateQuery(LazyQueryState.java:154)
      2. org.hibernate.search.query.engine.impl.LazyQueryState.search(LazyQueryState.java:98)
      3. org.hibernate.search.query.engine.impl.QueryHits.updateTopDocs(QueryHits.java:250)
      4. org.hibernate.search.query.engine.impl.QueryHits.<init>(QueryHits.java:145)
      5. org.hibernate.search.query.engine.impl.QueryHits.<init>(QueryHits.java:114)
      6. org.hibernate.search.query.engine.impl.HSQueryImpl.getQueryHits(HSQueryImpl.java:452)
      7. org.hibernate.search.query.engine.impl.HSQueryImpl.queryEntityInfos(HSQueryImpl.java:268)
      7 frames
    3. org.hibernate.search
      NumericIdEncodingTest.expectedProjections
      1. org.hibernate.search.test.id.NumericIdEncodingTest.expectedProjections(NumericIdEncodingTest.java:62)
      1 frame