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;
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
add a comment |
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
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
add a comment |
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
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
java solr apache-poi solrj
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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:
- 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"/>
As you have the actual document, you could just add a UUID to the "id" field.
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>
First of all thank u for your answer. I did option 2 and it gives me error like thatunknown 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 errorDocument 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
|
show 10 more comments
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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:
- 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"/>
As you have the actual document, you could just add a UUID to the "id" field.
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>
First of all thank u for your answer. I did option 2 and it gives me error like thatunknown 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 errorDocument 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
|
show 10 more comments
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:
- 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"/>
As you have the actual document, you could just add a UUID to the "id" field.
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>
First of all thank u for your answer. I did option 2 and it gives me error like thatunknown 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 errorDocument 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
|
show 10 more comments
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:
- 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"/>
As you have the actual document, you could just add a UUID to the "id" field.
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>
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:
- 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"/>
As you have the actual document, you could just add a UUID to the "id" field.
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>
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 thatunknown 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 errorDocument 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
|
show 10 more comments
First of all thank u for your answer. I did option 2 and it gives me error like thatunknown 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 errorDocument 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
|
show 10 more comments
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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