Reputation: 2637
I have a search query that contains quoted phrases and other words and would like to use spring-data-solr 1.0.
Here is an example query: dog "siamese cat" penguin
I've been trying something like,
new Criteria("myfield").contains("dog")
.and(new Criteria("myfield").contains("siamese cat"))
.and(new Criteria("myfield").contains("penguin"));
That was what I was trying until I saw that contains()
throws an exception when it contains spaces.
Lately I'm trying .expression()
but not sure how it works or if that's even a viable solution.
Any ideas? Thanks /w
Upvotes: 3
Views: 1248
Reputation: 2846
This works for me... since space is a special char just escape it:
new Criteria("myfield").expression("siamese\ cat")
Upvotes: 1
Reputation: 39
i solve it with expression:
new Criteria("myfield").expression("\"siamese cat\"")
Upvotes: 3