Answers.Body: <p>The search on text field should be exact match. Are you searching by exact name? Hope so there isn't any space at the start or end of the string!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-26T02:47:30.767Z
Answers.Text: So although my data appeared correct when viewing from CiviCRM, when I went back into the database to check it, I realized there was newline character at the end of every piece of data I inserted. Wrote a php script to remove that, and now working great... so the issue was PEBKAC :( but now it is solved!
Answers.UserDisplayName: jsherk
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-26T02:11:08.633Z
Answers.LastActivityDate: 2022-01-26T02:11:08.633Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>Is there a search index that needs to be updated so CiviCRM Advanced search can find custom field data that was added directly to the database?</p>
  <p>I created a custom field for Individuals (which is set to searchable).</p>
  <p>If I enter the data from within an Individuals account, and then use the Advanced search, it finds the data no problem in that custom field.</p>
  <p>However, I wrote a php script to import a large amount of data and add it to this custom field directly in the database (did not use CiviCRM API at all). When I go into an Individual account, I can see that the custom field is populated properly. But when I go to Advanced search and try to find any of the data using that custom field, it says &quot;No Matches found&quot;.</p>
  <p>What needs to happen for this data to be indexed and searchable?</p>
  <p>EDIT: I am using wordpress (just updated to v5.9), and am wondering if it could be a cache related issue, although I not using any caching plugins.</p>
  <p>EDIT: Issue was that data imported direct into database included a newline character on the end of each one... had to remove the newline character and then Advanced search started working as expected.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-01-26T01:58:10.227Z
Comments.Text: There isn't any indexing done, if they appear on contact record from GUI thn the search should be able to search. What field are you trying to do a search? Select/Multi-select/cehckbox/text?
Comments.UserDisplayName: Pradeep Nayak
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-01-26T02:01:15.677Z
Comments.Text: @PradeepNayak It is a text field (alphanumeric).
Comments.UserDisplayName: jsherk
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-01-26T02:10:00.220Z
Comments.Text: Are you searching by exact name?
Comments.UserDisplayName: Pradeep Nayak
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-02-02T09:37:32.250Z
Comments.Text: If you've found the solution, and it looks like you have, then you should post that as an answer.
Comments.UserDisplayName: Graham
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-02-02T13:41:40.967Z
Comments.Text: @Graham I selected pradeeps answer as correct already, and also posted the solution within the question already as well.
Comments.UserDisplayName: jsherk
Tags: <custom-fields><database>
Title: Is there a search index that needs to be updated so CiviCRM Advanced search can find custom field data that was added directly to the database?
ThreadText: # Is there a search index that needs to be updated so CiviCRM Advanced search can find custom field data that was added directly to the database?
  
  (Asked by: username_0 on 2022-01-26)
  
  Is there a search index that needs to be updated so CiviCRM Advanced search can find custom field data that was added directly to the database?
  
  I created a custom field for Individuals (which is set to searchable).
  
  If I enter the data from within an Individuals account, and then use the Advanced search, it finds the data no problem in that custom field.
  
  However, I wrote a php script to import a large amount of data and add it to this custom field directly in the database (did not use CiviCRM API at all). When I go into an Individual account, I can see that the custom field is populated properly. But when I go to Advanced search and try to find any of the data using that custom field, it says "No Matches found".
  
  What needs to happen for this data to be indexed and searchable?
  
  EDIT: I am using wordpress (just updated to v5.9), and am wondering if it could be a cache related issue, although I not using any caching plugins.
  
  EDIT: Issue was that data imported direct into database included a newline character on the end of each one... had to remove the newline character and then Advanced search started working as expected.
  
  **Tags:** custom-fields, database
  
  > **Comments:**
  > **username_1**: There isn't any indexing done, if they appear on contact record from GUI thn the search should be able to search. What field are you trying to do a search? Select/Multi-select/cehckbox/text?  
  > **username_0**: @username_1 It is a text field (alphanumeric).  
  > **username_1**: Are you searching by exact name?  
  > **username_2**: If you've found the solution, and it looks like you have, then you should post that as an answer.  
  > **username_0**: @username_2 I selected pradeeps answer as correct already, and also posted the solution within the question already as well.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-01-26. Score: 1 | Accepted answer
  
  The search on text field should be exact match. Are you searching by exact name? Hope so there isn't any space at the start or end of the string!
  
  > **Comments:**
  > **username_0**: So although my data appeared correct when viewing from CiviCRM, when I went back into the database to check it, I realized there was newline character at the end of every piece of data I inserted. Wrote a php script to remove that, and now working great... so the issue was PEBKAC :( but now it is solved!  
  
  ---
  
  