PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, October 24, 2022

[FIXED] How to allow ElasticSearch to accept empty date fields?

 October 24, 2022     elasticsearch, python     No comments   

Issue

I have a Python script that I use to load some data into ElasticSearch.

One of the fields I am loading is a date field, which on some rare occasions can be empty.

In my code, if there is no date, I assign it the string "null":

details["start_time"] = project_detail.get("start_time", "null")

In this case, I am getting the following error:

***search.BadRequestError: BadRequestError(400, 'mapper_parsing_exception', "failed to parse field [start_time] of type [date] in document with id '1'. Preview of field's value: 'null'")

How can I make ES accept empty fields for this date field?


Solution

"null" (string) is not the same as null. ES will not be able to parse "null" as a date. You should probably just assign None instead so that the date field will just be missing.



Answered By - Val
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing