# Error "Look-behind group does not have an obvious maximum length near index" in pattern\_capture

**URL:** <https://discuss.elastic.co/t/error-look-behind-group-does-not-have-an-obvious-maximum-length-near-index-in-pattern-capture/294594>\
**Category:** Elasticsearch\
**Created:** [January 17, 2022, 2:04pm UTC](https://discuss.elastic.co/t/error-look-behind-group-does-not-have-an-obvious-maximum-length-near-index-in-pattern-capture/294594 "2022-01-17T14:04:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amir\_Faramarzi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amir_faramarzi/32/92919_2.png) [@Amir\_Faramarzi](https://discuss.elastic.co/u/Amir_Faramarzi)\
**Post date:** [January 17, 2022, 2:04pm UTC](https://discuss.elastic.co/t/error-look-behind-group-does-not-have-an-obvious-maximum-length-near-index-in-pattern-capture/294594/1 "2022-01-17T14:04:48Z")

</div>

Hello

I just want to index the word "Samsung" in the text below

Text: Samsung a30 mobile phone

I mean I want to separate the text above by space and just index the word I want (the word may change by location, for example I might want to index the third or second word of the text)

I use [pattern\_capture](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-pattern-capture-tokenfilter.html) to do this

Pattern: `(?<=^(\W+\s){1})(\w+) `  
But I get the following error

Error:

```auto
{
  "error" : {
    "root_cause" : [
      {
        "type" : "pattern_syntax_exception",
        "reason" : "Look-behind group does not have an obvious maximum length near index 14\n(?<=^(\\w+\\s){1})(\\w+)\n ^"
      }
    ],
    "type" : "pattern_syntax_exception",
    "reason" : "Look-behind group does not have an obvious maximum length near index 14\n(?<=^(\\w+\\s){1})(\\w+)\n ^"
  },
  "status" : 400
}

```

Do you have a solution?

---

<div class="post-metadata">

**Author:** ![Amir\_Faramarzi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amir_faramarzi/32/92919_2.png) [@Amir\_Faramarzi](https://discuss.elastic.co/u/Amir_Faramarzi)\
**Post date:** [January 17, 2022, 4:08pm UTC](https://discuss.elastic.co/t/error-look-behind-group-does-not-have-an-obvious-maximum-length-near-index-in-pattern-capture/294594/2 "2022-01-17T16:08:08Z")

</div>

To do this you must use the [predicate\_token\_filter](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-predicatefilter-tokenfilter.html) filter

Sample code:

```auto
GET /_analyze
{
  "tokenizer": "whitespace",
  "filter": [
    {
      "type": "predicate_token_filter",
      "script": {
        "source": """
          token.getPosition() === 0
        """
      }
    }
  ],
  "text": "the fox jumps the lazy dog"
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 14, 2022, 4:08pm UTC](https://discuss.elastic.co/t/error-look-behind-group-does-not-have-an-obvious-maximum-length-near-index-in-pattern-capture/294594/3 "2022-02-14T16:08:12Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
