문제

I have been trying to do a lucene search query where entering "Foo B" would return "Foo Bar", Foo Bear, Foo Build" etc. but will not return a record with an ID of "Foo" and the word "Bar" in say its 'description' field.

I have looked into multiphrasequery but it never returns any results, below is what I have been trying

        Term firstTerm = new Term("jobTitle", "Entry");
        Term secondTerm = new Term("jobTitle", "Artist");
        Term asdTerm = new Term(fld)

        Term[] tTerms = new Term[]{firstTerm, secondTerm};
        MultiPhraseQuery multiPhrasequery = new MultiPhraseQuery();
            multiPhrasequery.add( tTerms );

             org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery(multiPhrasequery, this.type).setSort(sort);
         results = hibQuery.list();
도움이 되었습니까?

해결책

The likely problem that I see is capitalization. "Entry" and "Artist" are not getting passed through a query parser, and so will not be run through an analyzer, and so are case sensitive. The field you are indexing is probably analyzed with an analyzer that includes a LowercaseFilter, so the end terms would not contain leading capitals. Without knowing how you index your documents, I can't say that will fix it with any certainty, but it seems the most likely possibility.

That fixed, the query you've created should match anything with either the term "entry" or "artist" in the jobTitle field.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top