Does Solr have an equivalent of “strict order oper

2019-09-01 04:15发布

问题:

I'm choosing between Solr and Sphinx.

Sphinx doc page has a section called "5.3. Extended query syntax" which describes the following search parameters (among others) :

  • strict order operator (example: aaa << bbb << ccc) -
  • NEAR, generalized proximity operator (example: hello NEAR/3 world NEAR/4 "my test") - search according to distance between words
  • SENTENCE/PARAGRAPH (example: "Bill Gates" PARAGRAPH "Steve Jobs") - search inside a sentence/paragraph

Does Solr have any similar functionality?

回答1:

  • strict order operator: you would need to use SpanQueries for this, look at enter link description here for an explanation of SpanQuery, and in order to use them from Solr, you could try SurroundQParser or else see this other question
  • NEAR, generalized proximity operator: yes, this is supported, see Proximity search
  • SENTENCE/PARAGRAPH: not directly. You could try several approaches:
    • Map somehow those to documents (and maybe use Join functionality in 4.0 to link Paragraph documents to parent documents etc)
    • Try to insert information about paragraphs with special tokens/gaps, see this