Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search templates created with restapi are not deleteing completely #10397

Closed
kumar007007 opened this issue Apr 2, 2015 · 5 comments · Fixed by #10526
Closed

search templates created with restapi are not deleteing completely #10397

kumar007007 opened this issue Apr 2, 2015 · 5 comments · Fixed by #10526
Assignees
Labels
>bug :Search/Search Search-related issues that do not fall into other categories

Comments

@kumar007007
Copy link

We created a search templates with rest api will adds to .scripts index , when we delete the templete it says success and when we explore the index the templete won't appear .
When we recreate the search template with same name it will create , when we execute the template search it will take the old deleted template code . we updated to latest version 1.5 from 1.4.
You can easily replicate this issue ween u created a template with some wrong syntax , and delete that template and recreate with same name with valid syntax , then execute it wont work . I tried to flush cache on that index reorganize too

@clintongormley
Copy link

@kumar007007 could you provide a simple curl recreation which demonstrates the issue please?

@kumar007007
Copy link
Author

// new index

POST testindex/test
{
"searchtext": "dev1"
}

// creating template with wrong type to create error

POST _search/template/git01
{
"query": {
"match_all": {
"searchtext": {
"query": "{{P_Keyword1}}",
"type": "oooophrase_prefix"
}
}
}
}

// calling template it should error , it will give error

GET testindex/_search/template
{
"template": {"id": "git01"}
,
"params": {
"P_Keyword": "dev"
}
}

// fixing the template error by updating right type
POST _search/template/git01
{
"query": {
"match_all": {
"searchtext": {
"query": "{{P_Keyword1}}",
"type": "phrase_prefix"
}
}
}
}

// fixing the template error by deleting and recreating template
DELETE _search/template/git01

POST _search/template/git01
{
"query": {
"match_all": {
"searchtext": {
"query": "{{P_Keyword1}}",
"type": "phrase_prefix"
}
}
}
}
// using template still will give error

GET testindex/_search/template
{
"template": {"id": "git01"}
,
"params": {
"P_Keyword": "dev"
}
}

@clintongormley
Copy link

Hi @kumar007007

Your example didn't actually work, but it gave me enough to demonstrate the problem: existing templates never get reparsed, even when they are overwritten:

 # create test doc
POST testindex/test
{
  "searchtext": "dev1"
}

 # Create bad template
PUT _search/template/git01
{
  "query": {
    "match": {
      "searchtext": {
        "query": "{{P_Keyword1}}",
        "type": "ooophrase_prefix"
      }
    }
  }
}

 # Throws exception
GET testindex/_search/template
{
  "template": {
    "id": "git01"
  },
  "params": {
    "P_Keyword1": "dev"
  }
}

 # Overwrite with correct template
PUT _search/template/git01
{
  "query": {
    "match": {
      "searchtext": {
        "query": "{{P_Keyword1}}",
        "type": "phrase_prefix"
      }
    }
  }
}

 # Search fails with old error
GET testindex/_search/template
{
  "template": {
    "id": "git01"
  },
  "params": {
    "P_Keyword1": "dev"
  }
}

 # Create template with new ID
PUT _search/template/git02
{
  "query": {
    "match": {
      "searchtext": {
        "query": "{{P_Keyword1}}",
        "type": "phrase_prefix"
      }
    }
  }
}

 # Now it works correctly
GET testindex/_search/template
{
  "template": {
    "id": "git02"
  },
  "params": {
    "P_Keyword1": "dev"
  }
}

@clintongormley
Copy link

@MaineC coule you look at this one too please?

@ericbernal
Copy link

i have the same issue.. forcing us to resort to only managing templates from file and not index.
@MaineC show us some magic

MaineC pushed a commit to MaineC/elasticsearch that referenced this issue Apr 10, 2015
Closes elastic#10397

When putting new templates to an index they are added to the cache
of compiled templates as a side effect of the validate method. When
updating templates they are also validated but the scripts that are
already in the cache never get updated.
MaineC pushed a commit to MaineC/elasticsearch that referenced this issue Apr 21, 2015
Closes elastic#10397

When putting new templates to an index they are added to the cache
of compiled templates as a side effect of the validate method. When
updating templates they are also validated but the scripts that are
already in the cache never get updated.
MaineC pushed a commit to MaineC/elasticsearch that referenced this issue Apr 22, 2015
Closes elastic#10397

When putting new templates to an index they are added to the cache
of compiled templates as a side effect of the validate method. When
updating templates they are also validated but the scripts that are
already in the cache never get updated.

As per comments on PR elastic#10526 adding more tests around updating scripts
and templates.
MaineC pushed a commit to MaineC/elasticsearch that referenced this issue Apr 22, 2015
Closes elastic#10397

When putting new templates to an index they are added to the cache
of compiled templates as a side effect of the validate method. When
updating templates they are also validated but the scripts that are
already in the cache never get updated.

As per comments on PR elastic#10526 adding more tests around updating scripts
and templates.
MaineC pushed a commit that referenced this issue Apr 22, 2015
…not-recompiled

Closes #10397: Fix updating indexed search templates.
MaineC pushed a commit that referenced this issue Apr 24, 2015
See #10526 for more details.
MaineC pushed a commit that referenced this issue Apr 24, 2015
See #10526 for more details.
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Search Templates labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants