Hi, guys,
I have a question about highlight query in ES.
*Below is my query,*
{
  "_source": [
 
 .....
  ],
  "highlight": {
    "fields": {
      "FDS_ATTACHMENTS": {
        "type": "plain"
      },
      "FDS_ATTACHMENTS.no_stem": {
        "type": "plain"
      },
      "FDS_ATTACHMENTS.with_case": {
        "type": "plain"
      },
      "headline": {
        "type": "plain"
      },
      "headline.no_stem": {
        "type": "plain"
      },
      "headline.with_case": {
        "type": "plain"
      }
    },
    "fragment_size": 500,
    "highlight_query": {
      "bool": {
        "must": [
          {
            "bool": {
              "minimum_should_match": 1,
              "should": [
                {
                  "span_near": {
                    "clauses": [
                      {
                        "span_term": {
                          "FDS_ATTACHMENTS.no_stem": "rights"
                        }
                      },
                      {
                        "span_term": {
                          "FDS_ATTACHMENTS.no_stem": "agreement"
                        }
                      }
                    ],
                    "in_order": true,
                    "slop": 0
                  }
                }
              ]
            }
          },
          {
            "bool": {
              "minimum_should_match": 1,
              "should": [
                {
                  "span_near": {
                    "clauses": [
                      {
                        "span_term": {
                          "FDS_ATTACHMENTS.no_stem": "rights"
                        }
                      },
                      {
                        "span_term": {
                          "FDS_ATTACHMENTS.no_stem": "agreement"
                        }
                      },
                      {
                        "span_term": {
                          "FDS_ATTACHMENTS.no_stem": "merger"
                        }
                      }
                    ],
                    "in_order": false,
                    "slop": 5
                  }
                }
              ]
            }
          }
        ]
      }
    },
    "number_of_fragments": 50,
    "post_tags": [
      "</font>"
    ],
    "pre_tags": [
      "<font color=red>"
    ],
    "require_field_match": true
  },
  "query": {
    "filtered": {
      "filter": {
        "range": {
          "story_datetime": {
            "gte": "20141221t000000",
            "lte": "20141222t235959"
          }
        }
      },
      "query": {
        "bool": {
          "must": [
            {
              "bool": {
                "minimum_should_match": 1,
                "should": [
                  {
                    "span_near": {
                      "clauses": [
                        {
                          "span_term": {
                            "FDS_ATTACHMENTS.no_stem": "rights"
                          }
                        },
                        {
                          "span_term": {
                            "FDS_ATTACHMENTS.no_stem": "agreement"
                          }
                        }
                      ],
                      "in_order": true,
                      "slop": 0
                    }
                  },
                  {
                    "span_near": {
                      "clauses": [
                        {
                          "span_term": {
                            "headline.no_stem": "rights"
                          }
                        },
                        {
                          "span_term": {
                            "headline.no_stem": "agreement"
                          }
                        }
                      ],
                      "in_order": true,
                      "slop": 0
                    }
                  },
                  {
                    "span_near": {
                      "clauses": [
                        {
                          "span_term": {
                            "headline2.no_stem": "rights"
                          }
                        },
                        {
                          "span_term": {
                            "headline2.no_stem": "agreement"
                          }
                        }
                      ],
                      "in_order": true,
                      "slop": 0
                    }
                  }
                ]
              }
            },
            {
              "bool": {
                "minimum_should_match": 1,
                "should": [
                  {
                    "span_near": {
                      "clauses": [
                        {
                          "span_term": {
                            "FDS_ATTACHMENTS.no_stem": "rights"
                          }
                        },
                        {
                          "span_term": {
                            "FDS_ATTACHMENTS.no_stem": "agreement"
                          }
                        },
                        {
                          "span_term": {
                            "FDS_ATTACHMENTS.no_stem": "merger"
                          }
                        }
                      ],
                      "in_order": false,
                      "slop": 5
                    }
                  },
                  {
                    "span_near": {
                      "clauses": [
                        {
                          "span_term": {
                            "headline.no_stem": "rights"
                          }
                        },
                        {
                          "span_term": {
                            "headline.no_stem": "agreement"
                          }
                        },
                        {
                          "span_term": {
                            "headline.no_stem": "merger"
                          }
                        }
                      ],
                      "in_order": false,
                      "slop": 5
                    }
                  },
                  {
                    "span_near": {
                      "clauses": [
                        {
                          "span_term": {
                            "headline2.no_stem": "rights"
                          }
                        },
                        {
                          "span_term": {
                            "headline2.no_stem": "agreement"
                          }
                        },
                        {
                          "span_term": {
                            "headline2.no_stem": "merger"
                          }
                        }
                      ],
                      "in_order": false,
                      "slop": 5
                    }
                  }
                ]
              }
            }
          ]
        }
      }
    }
  },
  "size": 50,
  "sort": [
    {
      "_score": {
        "ignore_unmapped": true,
        "order": "desc"
      }
    },
    {
      "story_datetime": {
        "order": "desc"
      }
    }
  ]
}

And here is a response I got,

   -  of the Transactions set forth in the Offering Memorandum, and 
   redeeming the Notes, if applicable and (d) conducting such other activities 
   as are necessary or appropriate to carry out the activities described 
   above. Prior to the Merger Date, the Company shall not own, hold or 
   otherwise have any interest in any material assets other than cash and cash 
   equivalents and its <font color=red>rights</font> and obligations under the 
   <font color=red>Merger</font> <font color=red>Agreement</font>.   
   ARTICLE 5. SUCCESSORS   Section 5.01

You could see that the slop between <font color=red>rights</font> and <font 
color=red>Agreement</font> are definitely more than 0, not adjacent at all!
Could someone give me suggestions that how I can change the query to make 
sure that in all the segments, rights and agreement are adjacent.
I have set the slop to be 0 in the highlight query, and I don't know why ES 
not skip this segment, since it does not match the criteria.

Thank you very much!







-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/691af78c-5f9a-46f3-a54a-895421c1e28e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to