failed to map source {} to entity

Viewed 3173

I am getting the following error on reading a document from elasticsearch using Spring Data Elasticsearch:

ERROR SearchController - Nested Exception : failed to map source { document data } to Book

@Entity
@Table(name="books")
@Document(indexName="booksearchserver",type="book")
public class Book {
@org.springframework.data.annotation.Id
@Id
@Column(name="bookIsbn")
@Field(type = FieldType.Long, store = true)
private String bookIsbn;

@Column(name="bookTitle")
@Field(type = FieldType.String, store = true)
private String bookTitle;


@Column(name="authorId")
@Field(type = FieldType.Integer, store = true)
private int bookAuthorId;

@Column(name="bookLanguage")
@Field(type = FieldType.String, store = true)
private String bookLanguage;

@Column(name="bookPublisherId")
@Field(type = FieldType.Integer, store = true)
private short bookPublisherId;

@Column(name="bookReleaseDate")
@Field(type = FieldType.Date, store = true, format = DateFormat.custom, pattern="yyyy-MM-dd HH:mm:ss +SSSS")
private Date bookReleaseDate;

@JsonIgnore
@Column(name="bookNoOfChapters")
private short bookNoOfChapters;

@JsonIgnore
@Column(name="bookNoOfPages")
private short bookNoOfPages;

@JsonIgnore
@Column(name="bookNoOfWords")
private int bookWordCount;

@JsonIgnore
@Column(name="bookPrecededByIsbn" )
private long bookPrecededBy;

@JsonIgnore
@Column(name="bookFollowedByIsbn")
private long bookFollowedBy;

@Column(name="bookDescription")
@Field(type = FieldType.String, store = true )
private String bookDescription;

@JsonIgnore
@Column(name="bookCoverImage")
private String bookCover;

My Controller

@RequestMapping(value="/isbnSearch" ,method = RequestMethod.POST)
public String isbnSearch(@RequestParam("bookIsbn") String bookIsbn, Model m) {
    try{
        logger.info("Search for Book by ISBN:" + bookIsbn);
        Book book = searchServices.getBookByIsbn(bookIsbn);
        int authorId = book.getBookAuthorId();
        logger.info("Author ID is " + authorId );
        m.addAttribute("Book", book);
        return "showBook";
    }catch(Exception e){
        logger.error("Nested Exception : "+e.getMessage());
        m.addAttribute("error", e.getMessage());
        return "showError";
    }
}

SearchServerImpl

public Book getBookByIsbn(String isbn) {
//       try{
         Book book = esdao.findBybookIsbn(isbn);
         logger.info(""+ book.getBookTitle());
         return book;
//       }catch(ElasticsearchException ese){
//           logger.error("Nested Exception : " + ese.getMessage());
//           throw ese;
//       }catch(NullPointerException npe){
//           logger.error("Accessing NULL Class");
//           throw npe;
//       }
}

Esdao Repository

package co.in.searchServer.repository;

import org.elasticsearch.index.query.QueryBuilder;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

import co.in.searchServer.model.Book;

public interface ESDao extends ElasticsearchRepository<Book,String> {
    Iterable<Book> search(QueryBuilder arg0);
    Book findBybookIsbn(String isbn);
//  <S extends Book> S index(S arg0);
}

Please Provide me some suggestions and experiences on solving this

1 Answers
Related