Missing mandatory unique key field error in SolrJ Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceDocument is missing mandatory uniqueKey error in SolrJ using ContentStreamUpdateRequestAdding non-string fields with SolrJUpdate document field with solrjSolrJ: SolrQuery.setFields method for dynamic fieldsolrj search on particular fieldSolrJ: Field mappings by mixinWhy does SOLRJ fail with undefined field errorundefined field text SolrjError adding field SolrJ TikaSolrJ: Ignore fields on updatesolrJ error in HttpSolrServer and SolrServer

Unable to start mainnet node docker container

How did the aliens keep their waters separated?

Is above average number of years spent on PhD considered a red flag in future academia or industry positions?

When is phishing education going too far?

Simulating Exploding Dice

Fishing simulator

What do you call the holes in a flute?

Complexity of many constant time steps with occasional logarithmic steps

If A makes B more likely then B makes A more likely"

Cold is to Refrigerator as warm is to?

What are the performance impacts of 'functional' Rust?

When communicating altitude with a '9' in it, should it be pronounced "nine hundred" or "niner hundred"?

What is the electric potential inside a point charge?

What is the largest species of polychaete?

Two different pronunciation of "понял"

Writing Thesis: Copying from published papers

Can the prologue be the backstory of your main character?

What did Darwin mean by 'squib' here?

Stars Make Stars

Classification of bundles, Postnikov towers, obstruction theory, local coefficients

Keep going mode for require-package

Is there a documented rationale why the House Ways and Means chairman can demand tax info?

Do we know why communications with Beresheet and NASA were lost during the attempted landing of the Moon lander?

How to rotate it perfectly?



Missing mandatory unique key field error in SolrJ



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceDocument is missing mandatory uniqueKey error in SolrJ using ContentStreamUpdateRequestAdding non-string fields with SolrJUpdate document field with solrjSolrJ: SolrQuery.setFields method for dynamic fieldsolrj search on particular fieldSolrJ: Field mappings by mixinWhy does SOLRJ fail with undefined field errorundefined field text SolrjError adding field SolrJ TikaSolrJ: Ignore fields on updatesolrJ error in HttpSolrServer and SolrServer



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I've this issue in my project. I read my .xlsx excel file using Apache Poi and I want to index them in my Solr core. I use SolrInputDocument to index reading file. Here is my java codes



package org.solr;

import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.List;

import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrQuery.ORDER;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.XMLResponseParser;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;

public class PoiJava
private static final String fileName="C:\Users\FTK1187\Desktop\E-Archive - Copy\TableArchive.xlsx";

public static void main(String Args[]) throws SolrServerException
List dataList=getArchiveData();



private static List getArchiveData() throws SolrServerException
List dataList =new ArrayList();
FileInputStream excelFile=null;
try
excelFile = new FileInputStream(new File(fileName));
Workbook workbook = new XSSFWorkbook(excelFile);
Sheet datatypeSheet = workbook.getSheetAt(0);
Iterator<Row> iterator = datatypeSheet.iterator();
String urlString="http://localhost:8983/solr/archiveCore";
SolrClient solr=new HttpSolrClient.Builder(urlString).build();
SolrInputDocument document=new SolrInputDocument();
if(!document.isEmpty())

solr.deleteByQuery("*");
solr.commit();


while (iterator.hasNext())

Row currentRow = iterator.next();
Iterator<Cell> cellIterator = currentRow.iterator();

while (cellIterator.hasNext())

Cell currentCell = cellIterator.next();
//getCellTypeEnum shown as deprecated for version 3.15
//getCellTypeEnum ill be renamed to getCellType starting from version 4.0
if (currentCell.getCellTypeEnum() == CellType.STRING)
//System.out.println(currentCell.getStringCellValue());
for(int i=0;i<currentRow.getLastCellNum();i++)

if(currentCell.getColumnIndex()==1)

document.addField("NameAdded", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==2)

document.addField("DateAdded", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==3)

document.addField("NameModified", "");

else if(currentCell.getColumnIndex()==4)

document.addField("DateModified", "");

else if(currentCell.getColumnIndex()==5)

document.addField("strSO", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==6)

document.addField("strCust", "");

else if(currentCell.getColumnIndex()==7)

document.addField("strOperator", "");

else if(currentCell.getColumnIndex()==8)

document.addField("PackName", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==9)

document.addField("DocName", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==10)

document.addField("DocType", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==11)

document.addField("extType", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==12)

document.addField("FileName", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==13)

document.addField("FilePath", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==14)

document.addField("NameDeleted", "");

else if(currentCell.getColumnIndex()==15)

document.addField("DateDeleted", "");

else if(currentCell.getColumnIndex()==16)

document.addField("intRev", currentCell.getStringCellValue());





else if (currentCell.getCellTypeEnum() == CellType.NUMERIC)
//System.out.println(currentCell.getNumericCellValue());
for(int k=0;k<currentRow.getLastCellNum();k++)

if(currentCell.getColumnIndex()==0)

document.addField("id", currentCell.getNumericCellValue());





UpdateResponse response=solr.add(document);
solr.commit();


//System.out.println();
System.out.println(document.getField("id"));

catch (FileNotFoundException e)
e.printStackTrace();

catch(IOException e)
e.printStackTrace();

return dataList;




So when I'm running my project it gives me this error.



Exception in thread "main" org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://localhost:8983/solr/archiveCore: Document is missing mandatory uniqueKey field: id
at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:610)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:279)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:268)
at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:149)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:173)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:138)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:152)
at org.solr.PoiJava.getArchiveData(PoiJava.java:148)
at org.solr.PoiJava.main(PoiJava.java:33)


When I'm indexing files using SimplePostTool there is not error like that but I want to update my core in my web page.










share|improve this question
























  • check the document prepared by you..does it have id field every it is been created and posted to solr...

    – Abhijit Bashetti
    Mar 21 at 8:43











  • I checked it and it has id field... <uniqueKey>id</uniqueKey> this is in my schema.xml

    – Mustafa Berkan Demir
    Mar 21 at 8:53

















0















I've this issue in my project. I read my .xlsx excel file using Apache Poi and I want to index them in my Solr core. I use SolrInputDocument to index reading file. Here is my java codes



package org.solr;

import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.List;

import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrQuery.ORDER;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.XMLResponseParser;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;

public class PoiJava
private static final String fileName="C:\Users\FTK1187\Desktop\E-Archive - Copy\TableArchive.xlsx";

public static void main(String Args[]) throws SolrServerException
List dataList=getArchiveData();



private static List getArchiveData() throws SolrServerException
List dataList =new ArrayList();
FileInputStream excelFile=null;
try
excelFile = new FileInputStream(new File(fileName));
Workbook workbook = new XSSFWorkbook(excelFile);
Sheet datatypeSheet = workbook.getSheetAt(0);
Iterator<Row> iterator = datatypeSheet.iterator();
String urlString="http://localhost:8983/solr/archiveCore";
SolrClient solr=new HttpSolrClient.Builder(urlString).build();
SolrInputDocument document=new SolrInputDocument();
if(!document.isEmpty())

solr.deleteByQuery("*");
solr.commit();


while (iterator.hasNext())

Row currentRow = iterator.next();
Iterator<Cell> cellIterator = currentRow.iterator();

while (cellIterator.hasNext())

Cell currentCell = cellIterator.next();
//getCellTypeEnum shown as deprecated for version 3.15
//getCellTypeEnum ill be renamed to getCellType starting from version 4.0
if (currentCell.getCellTypeEnum() == CellType.STRING)
//System.out.println(currentCell.getStringCellValue());
for(int i=0;i<currentRow.getLastCellNum();i++)

if(currentCell.getColumnIndex()==1)

document.addField("NameAdded", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==2)

document.addField("DateAdded", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==3)

document.addField("NameModified", "");

else if(currentCell.getColumnIndex()==4)

document.addField("DateModified", "");

else if(currentCell.getColumnIndex()==5)

document.addField("strSO", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==6)

document.addField("strCust", "");

else if(currentCell.getColumnIndex()==7)

document.addField("strOperator", "");

else if(currentCell.getColumnIndex()==8)

document.addField("PackName", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==9)

document.addField("DocName", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==10)

document.addField("DocType", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==11)

document.addField("extType", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==12)

document.addField("FileName", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==13)

document.addField("FilePath", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==14)

document.addField("NameDeleted", "");

else if(currentCell.getColumnIndex()==15)

document.addField("DateDeleted", "");

else if(currentCell.getColumnIndex()==16)

document.addField("intRev", currentCell.getStringCellValue());





else if (currentCell.getCellTypeEnum() == CellType.NUMERIC)
//System.out.println(currentCell.getNumericCellValue());
for(int k=0;k<currentRow.getLastCellNum();k++)

if(currentCell.getColumnIndex()==0)

document.addField("id", currentCell.getNumericCellValue());





UpdateResponse response=solr.add(document);
solr.commit();


//System.out.println();
System.out.println(document.getField("id"));

catch (FileNotFoundException e)
e.printStackTrace();

catch(IOException e)
e.printStackTrace();

return dataList;




So when I'm running my project it gives me this error.



Exception in thread "main" org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://localhost:8983/solr/archiveCore: Document is missing mandatory uniqueKey field: id
at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:610)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:279)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:268)
at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:149)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:173)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:138)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:152)
at org.solr.PoiJava.getArchiveData(PoiJava.java:148)
at org.solr.PoiJava.main(PoiJava.java:33)


When I'm indexing files using SimplePostTool there is not error like that but I want to update my core in my web page.










share|improve this question
























  • check the document prepared by you..does it have id field every it is been created and posted to solr...

    – Abhijit Bashetti
    Mar 21 at 8:43











  • I checked it and it has id field... <uniqueKey>id</uniqueKey> this is in my schema.xml

    – Mustafa Berkan Demir
    Mar 21 at 8:53













0












0








0








I've this issue in my project. I read my .xlsx excel file using Apache Poi and I want to index them in my Solr core. I use SolrInputDocument to index reading file. Here is my java codes



package org.solr;

import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.List;

import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrQuery.ORDER;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.XMLResponseParser;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;

public class PoiJava
private static final String fileName="C:\Users\FTK1187\Desktop\E-Archive - Copy\TableArchive.xlsx";

public static void main(String Args[]) throws SolrServerException
List dataList=getArchiveData();



private static List getArchiveData() throws SolrServerException
List dataList =new ArrayList();
FileInputStream excelFile=null;
try
excelFile = new FileInputStream(new File(fileName));
Workbook workbook = new XSSFWorkbook(excelFile);
Sheet datatypeSheet = workbook.getSheetAt(0);
Iterator<Row> iterator = datatypeSheet.iterator();
String urlString="http://localhost:8983/solr/archiveCore";
SolrClient solr=new HttpSolrClient.Builder(urlString).build();
SolrInputDocument document=new SolrInputDocument();
if(!document.isEmpty())

solr.deleteByQuery("*");
solr.commit();


while (iterator.hasNext())

Row currentRow = iterator.next();
Iterator<Cell> cellIterator = currentRow.iterator();

while (cellIterator.hasNext())

Cell currentCell = cellIterator.next();
//getCellTypeEnum shown as deprecated for version 3.15
//getCellTypeEnum ill be renamed to getCellType starting from version 4.0
if (currentCell.getCellTypeEnum() == CellType.STRING)
//System.out.println(currentCell.getStringCellValue());
for(int i=0;i<currentRow.getLastCellNum();i++)

if(currentCell.getColumnIndex()==1)

document.addField("NameAdded", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==2)

document.addField("DateAdded", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==3)

document.addField("NameModified", "");

else if(currentCell.getColumnIndex()==4)

document.addField("DateModified", "");

else if(currentCell.getColumnIndex()==5)

document.addField("strSO", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==6)

document.addField("strCust", "");

else if(currentCell.getColumnIndex()==7)

document.addField("strOperator", "");

else if(currentCell.getColumnIndex()==8)

document.addField("PackName", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==9)

document.addField("DocName", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==10)

document.addField("DocType", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==11)

document.addField("extType", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==12)

document.addField("FileName", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==13)

document.addField("FilePath", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==14)

document.addField("NameDeleted", "");

else if(currentCell.getColumnIndex()==15)

document.addField("DateDeleted", "");

else if(currentCell.getColumnIndex()==16)

document.addField("intRev", currentCell.getStringCellValue());





else if (currentCell.getCellTypeEnum() == CellType.NUMERIC)
//System.out.println(currentCell.getNumericCellValue());
for(int k=0;k<currentRow.getLastCellNum();k++)

if(currentCell.getColumnIndex()==0)

document.addField("id", currentCell.getNumericCellValue());





UpdateResponse response=solr.add(document);
solr.commit();


//System.out.println();
System.out.println(document.getField("id"));

catch (FileNotFoundException e)
e.printStackTrace();

catch(IOException e)
e.printStackTrace();

return dataList;




So when I'm running my project it gives me this error.



Exception in thread "main" org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://localhost:8983/solr/archiveCore: Document is missing mandatory uniqueKey field: id
at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:610)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:279)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:268)
at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:149)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:173)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:138)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:152)
at org.solr.PoiJava.getArchiveData(PoiJava.java:148)
at org.solr.PoiJava.main(PoiJava.java:33)


When I'm indexing files using SimplePostTool there is not error like that but I want to update my core in my web page.










share|improve this question
















I've this issue in my project. I read my .xlsx excel file using Apache Poi and I want to index them in my Solr core. I use SolrInputDocument to index reading file. Here is my java codes



package org.solr;

import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.List;

import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrQuery.ORDER;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.XMLResponseParser;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;

public class PoiJava
private static final String fileName="C:\Users\FTK1187\Desktop\E-Archive - Copy\TableArchive.xlsx";

public static void main(String Args[]) throws SolrServerException
List dataList=getArchiveData();



private static List getArchiveData() throws SolrServerException
List dataList =new ArrayList();
FileInputStream excelFile=null;
try
excelFile = new FileInputStream(new File(fileName));
Workbook workbook = new XSSFWorkbook(excelFile);
Sheet datatypeSheet = workbook.getSheetAt(0);
Iterator<Row> iterator = datatypeSheet.iterator();
String urlString="http://localhost:8983/solr/archiveCore";
SolrClient solr=new HttpSolrClient.Builder(urlString).build();
SolrInputDocument document=new SolrInputDocument();
if(!document.isEmpty())

solr.deleteByQuery("*");
solr.commit();


while (iterator.hasNext())

Row currentRow = iterator.next();
Iterator<Cell> cellIterator = currentRow.iterator();

while (cellIterator.hasNext())

Cell currentCell = cellIterator.next();
//getCellTypeEnum shown as deprecated for version 3.15
//getCellTypeEnum ill be renamed to getCellType starting from version 4.0
if (currentCell.getCellTypeEnum() == CellType.STRING)
//System.out.println(currentCell.getStringCellValue());
for(int i=0;i<currentRow.getLastCellNum();i++)

if(currentCell.getColumnIndex()==1)

document.addField("NameAdded", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==2)

document.addField("DateAdded", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==3)

document.addField("NameModified", "");

else if(currentCell.getColumnIndex()==4)

document.addField("DateModified", "");

else if(currentCell.getColumnIndex()==5)

document.addField("strSO", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==6)

document.addField("strCust", "");

else if(currentCell.getColumnIndex()==7)

document.addField("strOperator", "");

else if(currentCell.getColumnIndex()==8)

document.addField("PackName", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==9)

document.addField("DocName", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==10)

document.addField("DocType", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==11)

document.addField("extType", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==12)

document.addField("FileName", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==13)

document.addField("FilePath", currentCell.getStringCellValue());

else if(currentCell.getColumnIndex()==14)

document.addField("NameDeleted", "");

else if(currentCell.getColumnIndex()==15)

document.addField("DateDeleted", "");

else if(currentCell.getColumnIndex()==16)

document.addField("intRev", currentCell.getStringCellValue());





else if (currentCell.getCellTypeEnum() == CellType.NUMERIC)
//System.out.println(currentCell.getNumericCellValue());
for(int k=0;k<currentRow.getLastCellNum();k++)

if(currentCell.getColumnIndex()==0)

document.addField("id", currentCell.getNumericCellValue());





UpdateResponse response=solr.add(document);
solr.commit();


//System.out.println();
System.out.println(document.getField("id"));

catch (FileNotFoundException e)
e.printStackTrace();

catch(IOException e)
e.printStackTrace();

return dataList;




So when I'm running my project it gives me this error.



Exception in thread "main" org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://localhost:8983/solr/archiveCore: Document is missing mandatory uniqueKey field: id
at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:610)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:279)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:268)
at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:149)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:173)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:138)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:152)
at org.solr.PoiJava.getArchiveData(PoiJava.java:148)
at org.solr.PoiJava.main(PoiJava.java:33)


When I'm indexing files using SimplePostTool there is not error like that but I want to update my core in my web page.







java solr apache-poi solrj






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 21 at 7:59







Mustafa Berkan Demir

















asked Mar 21 at 7:09









Mustafa Berkan DemirMustafa Berkan Demir

508




508












  • check the document prepared by you..does it have id field every it is been created and posted to solr...

    – Abhijit Bashetti
    Mar 21 at 8:43











  • I checked it and it has id field... <uniqueKey>id</uniqueKey> this is in my schema.xml

    – Mustafa Berkan Demir
    Mar 21 at 8:53

















  • check the document prepared by you..does it have id field every it is been created and posted to solr...

    – Abhijit Bashetti
    Mar 21 at 8:43











  • I checked it and it has id field... <uniqueKey>id</uniqueKey> this is in my schema.xml

    – Mustafa Berkan Demir
    Mar 21 at 8:53
















check the document prepared by you..does it have id field every it is been created and posted to solr...

– Abhijit Bashetti
Mar 21 at 8:43





check the document prepared by you..does it have id field every it is been created and posted to solr...

– Abhijit Bashetti
Mar 21 at 8:43













I checked it and it has id field... <uniqueKey>id</uniqueKey> this is in my schema.xml

– Mustafa Berkan Demir
Mar 21 at 8:53





I checked it and it has id field... <uniqueKey>id</uniqueKey> this is in my schema.xml

– Mustafa Berkan Demir
Mar 21 at 8:53












1 Answer
1






active

oldest

votes


















2














You probably have in your schema a field set as the unique key like this:



<uniqueKey>id</uniqueKey>


The problem is that when you upload a doc, in this case via Apache POI, you are not sending a value for that unique field.



You have a couple options:



  1. If you do have a field that will be unique, use it. For example, with a copyField option like:

<copyField source="excel_guaranteed_unique" dest="id"/>




  1. As you have the actual document, you could just add a UUID to the "id" field.


  2. Create a unique field like a UUID updating your RequestHandlder, like this:


<updateRequestProcessorChain name="uuid" >
<processor class="solr.UUIDUpdateProcessorFactory">
<str name="fieldName">id</str>
</processor>
...
</updateRequestProcessorChain>
...
<requestHandler name="/update" class="solr.UpdateRequestHandler">
<lst name="defaults">
<str name="update.chain">uuid</str>
</lst>
</requestHandler>




You also need to update the extract handler:



 <requestHandler name="/update/extract"
startup="lazy"
class="solr.extraction.ExtractingRequestHandler" >
<lst name="defaults">
...
<str name="update.chain">uuid</str>
</lst>







share|improve this answer

























  • First of all thank u for your answer. I did option 2 and it gives me error like that unknown UpdateRequestProcessorChain: uuid

    – Mustafa Berkan Demir
    Mar 21 at 9:12











  • I updated the answer to use the uuid updated in the extract handler

    – s1m3n
    Mar 21 at 9:22











  • I updated extract handler but it gives me first error Document is missing mandatory uniqueKey field: id :(

    – Mustafa Berkan Demir
    Mar 21 at 10:01











  • Your java code sets the "id" in some condition document.addField("id", currentCell.getNumericCellValue()); Have you tried setting it always with a UUID of your own?

    – s1m3n
    Mar 21 at 10:10











  • No, I didn't also I don't know how I'm doing it.

    – Mustafa Berkan Demir
    Mar 21 at 10:24











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55275348%2fmissing-mandatory-unique-key-field-error-in-solrj%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














You probably have in your schema a field set as the unique key like this:



<uniqueKey>id</uniqueKey>


The problem is that when you upload a doc, in this case via Apache POI, you are not sending a value for that unique field.



You have a couple options:



  1. If you do have a field that will be unique, use it. For example, with a copyField option like:

<copyField source="excel_guaranteed_unique" dest="id"/>




  1. As you have the actual document, you could just add a UUID to the "id" field.


  2. Create a unique field like a UUID updating your RequestHandlder, like this:


<updateRequestProcessorChain name="uuid" >
<processor class="solr.UUIDUpdateProcessorFactory">
<str name="fieldName">id</str>
</processor>
...
</updateRequestProcessorChain>
...
<requestHandler name="/update" class="solr.UpdateRequestHandler">
<lst name="defaults">
<str name="update.chain">uuid</str>
</lst>
</requestHandler>




You also need to update the extract handler:



 <requestHandler name="/update/extract"
startup="lazy"
class="solr.extraction.ExtractingRequestHandler" >
<lst name="defaults">
...
<str name="update.chain">uuid</str>
</lst>







share|improve this answer

























  • First of all thank u for your answer. I did option 2 and it gives me error like that unknown UpdateRequestProcessorChain: uuid

    – Mustafa Berkan Demir
    Mar 21 at 9:12











  • I updated the answer to use the uuid updated in the extract handler

    – s1m3n
    Mar 21 at 9:22











  • I updated extract handler but it gives me first error Document is missing mandatory uniqueKey field: id :(

    – Mustafa Berkan Demir
    Mar 21 at 10:01











  • Your java code sets the "id" in some condition document.addField("id", currentCell.getNumericCellValue()); Have you tried setting it always with a UUID of your own?

    – s1m3n
    Mar 21 at 10:10











  • No, I didn't also I don't know how I'm doing it.

    – Mustafa Berkan Demir
    Mar 21 at 10:24















2














You probably have in your schema a field set as the unique key like this:



<uniqueKey>id</uniqueKey>


The problem is that when you upload a doc, in this case via Apache POI, you are not sending a value for that unique field.



You have a couple options:



  1. If you do have a field that will be unique, use it. For example, with a copyField option like:

<copyField source="excel_guaranteed_unique" dest="id"/>




  1. As you have the actual document, you could just add a UUID to the "id" field.


  2. Create a unique field like a UUID updating your RequestHandlder, like this:


<updateRequestProcessorChain name="uuid" >
<processor class="solr.UUIDUpdateProcessorFactory">
<str name="fieldName">id</str>
</processor>
...
</updateRequestProcessorChain>
...
<requestHandler name="/update" class="solr.UpdateRequestHandler">
<lst name="defaults">
<str name="update.chain">uuid</str>
</lst>
</requestHandler>




You also need to update the extract handler:



 <requestHandler name="/update/extract"
startup="lazy"
class="solr.extraction.ExtractingRequestHandler" >
<lst name="defaults">
...
<str name="update.chain">uuid</str>
</lst>







share|improve this answer

























  • First of all thank u for your answer. I did option 2 and it gives me error like that unknown UpdateRequestProcessorChain: uuid

    – Mustafa Berkan Demir
    Mar 21 at 9:12











  • I updated the answer to use the uuid updated in the extract handler

    – s1m3n
    Mar 21 at 9:22











  • I updated extract handler but it gives me first error Document is missing mandatory uniqueKey field: id :(

    – Mustafa Berkan Demir
    Mar 21 at 10:01











  • Your java code sets the "id" in some condition document.addField("id", currentCell.getNumericCellValue()); Have you tried setting it always with a UUID of your own?

    – s1m3n
    Mar 21 at 10:10











  • No, I didn't also I don't know how I'm doing it.

    – Mustafa Berkan Demir
    Mar 21 at 10:24













2












2








2







You probably have in your schema a field set as the unique key like this:



<uniqueKey>id</uniqueKey>


The problem is that when you upload a doc, in this case via Apache POI, you are not sending a value for that unique field.



You have a couple options:



  1. If you do have a field that will be unique, use it. For example, with a copyField option like:

<copyField source="excel_guaranteed_unique" dest="id"/>




  1. As you have the actual document, you could just add a UUID to the "id" field.


  2. Create a unique field like a UUID updating your RequestHandlder, like this:


<updateRequestProcessorChain name="uuid" >
<processor class="solr.UUIDUpdateProcessorFactory">
<str name="fieldName">id</str>
</processor>
...
</updateRequestProcessorChain>
...
<requestHandler name="/update" class="solr.UpdateRequestHandler">
<lst name="defaults">
<str name="update.chain">uuid</str>
</lst>
</requestHandler>




You also need to update the extract handler:



 <requestHandler name="/update/extract"
startup="lazy"
class="solr.extraction.ExtractingRequestHandler" >
<lst name="defaults">
...
<str name="update.chain">uuid</str>
</lst>







share|improve this answer















You probably have in your schema a field set as the unique key like this:



<uniqueKey>id</uniqueKey>


The problem is that when you upload a doc, in this case via Apache POI, you are not sending a value for that unique field.



You have a couple options:



  1. If you do have a field that will be unique, use it. For example, with a copyField option like:

<copyField source="excel_guaranteed_unique" dest="id"/>




  1. As you have the actual document, you could just add a UUID to the "id" field.


  2. Create a unique field like a UUID updating your RequestHandlder, like this:


<updateRequestProcessorChain name="uuid" >
<processor class="solr.UUIDUpdateProcessorFactory">
<str name="fieldName">id</str>
</processor>
...
</updateRequestProcessorChain>
...
<requestHandler name="/update" class="solr.UpdateRequestHandler">
<lst name="defaults">
<str name="update.chain">uuid</str>
</lst>
</requestHandler>




You also need to update the extract handler:



 <requestHandler name="/update/extract"
startup="lazy"
class="solr.extraction.ExtractingRequestHandler" >
<lst name="defaults">
...
<str name="update.chain">uuid</str>
</lst>








share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 21 at 9:21

























answered Mar 21 at 9:03









s1m3ns1m3n

523417




523417












  • First of all thank u for your answer. I did option 2 and it gives me error like that unknown UpdateRequestProcessorChain: uuid

    – Mustafa Berkan Demir
    Mar 21 at 9:12











  • I updated the answer to use the uuid updated in the extract handler

    – s1m3n
    Mar 21 at 9:22











  • I updated extract handler but it gives me first error Document is missing mandatory uniqueKey field: id :(

    – Mustafa Berkan Demir
    Mar 21 at 10:01











  • Your java code sets the "id" in some condition document.addField("id", currentCell.getNumericCellValue()); Have you tried setting it always with a UUID of your own?

    – s1m3n
    Mar 21 at 10:10











  • No, I didn't also I don't know how I'm doing it.

    – Mustafa Berkan Demir
    Mar 21 at 10:24

















  • First of all thank u for your answer. I did option 2 and it gives me error like that unknown UpdateRequestProcessorChain: uuid

    – Mustafa Berkan Demir
    Mar 21 at 9:12











  • I updated the answer to use the uuid updated in the extract handler

    – s1m3n
    Mar 21 at 9:22











  • I updated extract handler but it gives me first error Document is missing mandatory uniqueKey field: id :(

    – Mustafa Berkan Demir
    Mar 21 at 10:01











  • Your java code sets the "id" in some condition document.addField("id", currentCell.getNumericCellValue()); Have you tried setting it always with a UUID of your own?

    – s1m3n
    Mar 21 at 10:10











  • No, I didn't also I don't know how I'm doing it.

    – Mustafa Berkan Demir
    Mar 21 at 10:24
















First of all thank u for your answer. I did option 2 and it gives me error like that unknown UpdateRequestProcessorChain: uuid

– Mustafa Berkan Demir
Mar 21 at 9:12





First of all thank u for your answer. I did option 2 and it gives me error like that unknown UpdateRequestProcessorChain: uuid

– Mustafa Berkan Demir
Mar 21 at 9:12













I updated the answer to use the uuid updated in the extract handler

– s1m3n
Mar 21 at 9:22





I updated the answer to use the uuid updated in the extract handler

– s1m3n
Mar 21 at 9:22













I updated extract handler but it gives me first error Document is missing mandatory uniqueKey field: id :(

– Mustafa Berkan Demir
Mar 21 at 10:01





I updated extract handler but it gives me first error Document is missing mandatory uniqueKey field: id :(

– Mustafa Berkan Demir
Mar 21 at 10:01













Your java code sets the "id" in some condition document.addField("id", currentCell.getNumericCellValue()); Have you tried setting it always with a UUID of your own?

– s1m3n
Mar 21 at 10:10





Your java code sets the "id" in some condition document.addField("id", currentCell.getNumericCellValue()); Have you tried setting it always with a UUID of your own?

– s1m3n
Mar 21 at 10:10













No, I didn't also I don't know how I'm doing it.

– Mustafa Berkan Demir
Mar 21 at 10:24





No, I didn't also I don't know how I'm doing it.

– Mustafa Berkan Demir
Mar 21 at 10:24



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55275348%2fmissing-mandatory-unique-key-field-error-in-solrj%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현