java - Autocomplete using Solr & Spring - issue with multiple words -


i have indexed database of locations using spring data solr. have following fields:

   <field name="id" type="string" indexed="true" stored="true" required="true" multivalued="false" />     <field name="name" type="text_ws" indexed="true" stored="true"/>    <field name="autocomplete" type="lowercase" indexed="true" stored="false"/> 

i trying implement autocomplete feature. ajax call handled controller calls repository with:

list<poisearch> findbyautocompletestartingwith(string autocomplete, pageable pageable); 

this works fine search "california" or "los". when try multiple words "los ang" exception:

severe: servlet.service() servlet [spring-mvc] in context path [/xxx] threw exception [request processing failed; nested exception org.springframework.dao.invaliddataaccessapiusageexception: cannot constructquery '"los an"'. use epxression or mulitple clauses instead.] root cause org.springframework.dao.invaliddataaccessapiusageexception: cannot constructquery '"los an"'. use epxression or mulitple clauses instead. @ org.springframework.data.solr.core.query.criteria.assertnoblankinwildcardedquery(criteria.java:596) @ org.springframework.data.solr.core.query.criteria.contains(criteria.java:230) @ org.springframework.data.solr.core.query.criteria.contains(criteria.java:257) @ org.springframework.data.solr.core.query.criteria.contains(criteria.java:244) @ org.springframework.data.solr.repository.query.solrquerycreator.from(solrquerycreator.java:112) @ org.springframework.data.solr.repository.query.solrquerycreator.create(solrquerycreator.java:56) @ org.springframework.data.solr.repository.query.solrquerycreator.create(solrquerycreator.java:43) @ org.springframework.data.repository.query.parser.abstractquerycreator.createcriteria(abstractquerycreator.java:109) @ org.springframework.data.repository.query.parser.abstractquerycreator.createquery(abstractquerycreator.java:88) @ org.springframework.data.repository.query.parser.abstractquerycreator.createquery(abstractquerycreator.java:73) @ org.springframework.data.solr.repository.query.parttreesolrquery.createquery(parttreesolrquery.java:46) @ org.springframework.data.solr.repository.query.abstractsolrquery.execute(abstractsolrquery.java:95) @ org.springframework.data.repository.core.support.repositoryfactorysupport$queryexecutormethodinterceptor.invoke(repositoryfactorysupport.java:312) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172) @ org.springframework.transaction.interceptor.transactioninterceptor$1.proceedwithinvocation(transactioninterceptor.java:96) @ org.springframework.transaction.interceptor.transactionaspectsupport.invokewithintransaction(transactionaspectsupport.java:260) @ org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:94) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172) @ org.springframework.dao.support.persistenceexceptiontranslationinterceptor.invoke(persistenceexceptiontranslationinterceptor.java:155) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172) @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:204) @ $proxy44.findbyautocompletecontaining(unknown source)

any ideas how solve?

with latest version of spring-data-solr can following:

list<poisearch> results = repository.findbyautocompletestartingwith(arrays.aslist("los", "ange")); 

works great!

thanks christoph helping answer: https://jira.springsource.org/browse/datasolr-74


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -