Body: <p>Is it possible for us to manually inject our own <code>keywords</code> into the <code>searchindex</code> via an event or something? eg.</p>
  <pre class="lang-php prettyprint-override"><code>Event::on(Entry::class, Entry::EVENT_AFTER_SAVE, function (ModelEvent $event) {
      $event-&gt;sender-&gt;addKeywords('blah blah blah');
  });
  </code></pre>
  <p>We want to be able to automatically append extra keywords to some posts to increase the searchability, e.g. The Author name, API results etc.</p>
  <p>Thanks</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-10-09T15:26:56.110Z
Comments.Text: We add a plain text field and add comma separated values to that, which is probably the most suitable method.
Comments.UserDisplayName: Joshua M
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-10-13T11:45:40.163Z
Comments.Text: This would be visible to the user though? and wouldn't automatically populate with internal values?
Comments.UserDisplayName: owenmelbz
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-10-15T14:11:23.590Z
Comments.Text: Visible to the client user, or visible to the customer on the front end? It wont be visible on the front end unless you output it. You can populate it with internal values using the AFTER_SAVE function and `setFieldValues()`.
Comments.UserDisplayName: Joshua M
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-10-15T17:02:04.453Z
Comments.Text: We don't want anybody to be able to see it, it should purely exist in code-land really
Comments.UserDisplayName: owenmelbz
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-10-20T12:45:10.373Z
Comments.Text: Also this would create an infinite loop. When i save the element, it will trigger AFTER_SAVE, which will run my code etc etc
Comments.UserDisplayName: owenmelbz
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-10-20T14:35:45.313Z
Comments.Text: True–you should do it on `BEFORE_SAVE`. Not sure regarding hiding the field–if we need to do something like this, we generally expose it anyway because in our experience the user sometimes wants to add their own keywords beyond the defaults.
Comments.UserDisplayName: Joshua M
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-10-20T15:40:20.310Z
Comments.Text: If we try use before_save it seems to do nothing, when we modify the values it doesn't persist them.
Comments.UserDisplayName: owenmelbz
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-10-21T09:31:15.447Z
Comments.Text: That's probably for a different question :)
Comments.UserDisplayName: Joshua M
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-10-21T09:48:41.133Z
Comments.Text: I don't feel it is xD The question was "how to add keywords" and if the answer is "add a custom input and populate it" it doesn't explain the "how" just "what to do" - e.g. "What must we do to end world hunger?- Get food and money to everybody" - How though... How can you do that xD
Comments.UserDisplayName: owenmelbz
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-10-21T09:58:28.700Z
Comments.Text: Right.. but your question is 'How do I add keywords' of which the 'how' is create a custom field and use an event to push data to it. Having problems with using `BEFORE_SAVE` is a question of 'How do I push data to a custom field using `BEFORE_SAVE`'
Comments.UserDisplayName: Joshua M
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-10-21T13:24:53.807Z
Comments.Text: I think thats the "what" xD What you need to do is... create a custom field.. but How :P
Comments.UserDisplayName: owenmelbz
Tags: <search>
Title: Adding custom "keywords" to the search index
ThreadText: # Adding custom "keywords" to the search index
  
  (Asked by: username_0 on 2020-10-09)
  
  Is it possible for us to manually inject our own `keywords` into the `searchindex` via an event or something? eg.
  
  ```php
  Event::on(Entry::class, Entry::EVENT_AFTER_SAVE, function (ModelEvent $event) {
      $event->sender->addKeywords('blah blah blah');
  });
  
  ```
  
  We want to be able to automatically append extra keywords to some posts to increase the searchability, e.g. The Author name, API results etc.
  
  Thanks
  
  **Tags:** search
  
  > **Comments:**
  > **username_1**: We add a plain text field and add comma separated values to that, which is probably the most suitable method.  
  > **username_0**: This would be visible to the user though? and wouldn't automatically populate with internal values?  
  > **username_1**: Visible to the client user, or visible to the customer on the front end? It wont be visible on the front end unless you output it. You can populate it with internal values using the AFTER_SAVE function and `setFieldValues()`.  
  > **username_0**: We don't want anybody to be able to see it, it should purely exist in code-land really  
  > **username_0**: Also this would create an infinite loop. When i save the element, it will trigger AFTER_SAVE, which will run my code etc etc  
  > **username_1**: True–you should do it on `BEFORE_SAVE`. Not sure regarding hiding the field–if we need to do something like this, we generally expose it anyway because in our experience the user sometimes wants to add their own keywords beyond the defaults.  
  > **username_0**: If we try use before_save it seems to do nothing, when we modify the values it doesn't persist them.  
  > **username_1**: That's probably for a different question :)  
  > **username_0**: I don't feel it is xD The question was "how to add keywords" and if the answer is "add a custom input and populate it" it doesn't explain the "how" just "what to do" - e.g. "What must we do to end world hunger?- Get food and money to everybody" - How though... How can you do that xD  
  > **username_1**: Right.. but your question is 'How do I add keywords' of which the 'how' is create a custom field and use an event to push data to it. Having problems with using `BEFORE_SAVE` is a question of 'How do I push data to a custom field using `BEFORE_SAVE`'  
  > **username_0**: I think thats the "what" xD What you need to do is... create a custom field.. but How :P  
  
  ---
  
  ## 0 answers
  
  