You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tika.apache.org by raju <lo...@gmail.com> on 2014/11/13 11:38:45 UTC
error Unsupported Media Type : while implementing
ContentStreamUpdateRequestExample from the link
http://wiki.apache.org/solr/ContentStreamUpdateRequestExample
Hi Team,
I am getting the error org.apache.solr.common.SolrException: Unsupported
Media Type
Unsupported Media Type
I have used the code from
http://wiki.apache.org/solr/ContentStreamUpdateRequestExample
could some body help me, to me it is failing when it encounters the code
solr.request(up);
package javaapplicationsolrcell;
import java.io.File;
import java.io.IOException;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest;
/**
* @author EDaniel
*/
public class SolrExampleTests {
public static void main(String[] args) {
try {
//Solr cell can also index MS file (2003 version and 2007 version)
types.
String fileName = "c:/Sample.pdf";
//this will be unique Id used by Solr to index the file contents.
String solrId = "Sample.pdf";
indexFilesSolrCell(fileName, solrId);
} catch (Exception ex) {
System.out.println(ex.toString());
}
}
/**
* Method to index all types of files into Solr.
* @param fileName
* @param solrId
* @throws IOException
* @throws SolrServerException
*/
public static void indexFilesSolrCell(String fileName, String solrId)
throws IOException, SolrServerException {
String urlString = "http://localhost:8983/solr";
SolrServer solr = new CommonsHttpSolrServer(urlString);
ContentStreamUpdateRequest up
= new ContentStreamUpdateRequest("/update/extract");
up.addFile(new File(fileName));
up.setParam("literal.id", solrId);
up.setParam("uprefix", "attr_");
up.setParam("fmap.content", "attr_content");
up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
solr.request(up);
QueryResponse rsp = solr.query(new SolrQuery("*:*"));
System.out.println(rsp);
}
}
Thanks
raju
--
View this message in context: http://lucene.472066.n3.nabble.com/error-Unsupported-Media-Type-while-implementing-ContentStreamUpdateRequestExample-from-the-link-httpe-tp4169035.html
Sent from the Apache Tika - Development mailing list archive at Nabble.com.
FW: error Unsupported Media Type : while implementing
ContentStreamUpdateRequestExample from the link
http://wiki.apache.org/solr/ContentStreamUpdateRequestExample
Posted by "Allison, Timothy B." <ta...@mitre.org>.
What happens when you run straight tika-app against that pdf file?
java -jar tika-app.jar Sample.pdf
(grab tika-app from: http://www.apache.org/dyn/closer.cgi/tika/tika-app-1.9.jar)
Do you have all of the tika jars on your classpath/properly configured within your Solr setup?
-----Original Message-----
From: Kathrincolyn [mailto:kathrincolyn@yahoo.in]
Sent: Wednesday, July 22, 2015 5:57 AM
To: tika-dev@lucene.apache.org
Subject: Re: error Unsupported Media Type : while implementing ContentStreamUpdateRequestExample from the link http://wiki.apache.org/solr/ContentStreamUpdateRequestExample
public class SolrExampleTests {
>
> public static void main(String[] args) {
> try {
> //Solr cell can also index MS file (2003 version and 2007 version)
> types.
> String fileName = "c:/Sample.pdf";
> //this will be unique Id used by Solr to index the file contents.
> String solrId = "Sample.pdf";
>
> indexFilesSolrCell(fileName, solrId);
>
> } catch (Exception ex) {
> System.out.println(ex.toString());
> }
> }
>
> /**
> * Method to index all types of files into Solr.
> * @param fileName
> * @param solrId
> * @throws IOException
> * @throws SolrServerException
> */
> public static void indexFilesSolrCell(String fileName, String solrId)
> throws IOException, SolrServerException {
>
> String urlString = "http://localhost:8983/solr";
> SolrServer solr = new CommonsHttpSolrServer(urlString);
>
> ContentStreamUpdateRequest up
> = new ContentStreamUpdateRequest("/update/extract");
>
> up.addFile(new File(fileName));
>
> up.setParam("literal.id", solrId);
> up.setParam("uprefix", "attr_");
> up.setParam("fmap.content", "attr_content");
>
> up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
>
> solr.request(up);
>
> QueryResponse rsp = solr.query(new SolrQuery("*:*"));
>
> System.out.println(rsp);
> }
> }
>
> Thanks
Ufindthem <http://www.ufindthem.com>
--
View this message in context: http://lucene.472066.n3.nabble.com/error-Unsupported-Media-Type-while-implementing-ContentStreamUpdateRequestExample-from-the-link-httpe-tp4169035p4218516.html
Sent from the Apache Tika - Development mailing list archive at Nabble.com.
Re: error Unsupported Media Type : while implementing
ContentStreamUpdateRequestExample from the link
http://wiki.apache.org/solr/ContentStreamUpdateRequestExample
Posted by Kathrincolyn <ka...@yahoo.in>.
public class SolrExampleTests {
>
> public static void main(String[] args) {
> try {
> //Solr cell can also index MS file (2003 version and 2007 version)
> types.
> String fileName = "c:/Sample.pdf";
> //this will be unique Id used by Solr to index the file contents.
> String solrId = "Sample.pdf";
>
> indexFilesSolrCell(fileName, solrId);
>
> } catch (Exception ex) {
> System.out.println(ex.toString());
> }
> }
>
> /**
> * Method to index all types of files into Solr.
> * @param fileName
> * @param solrId
> * @throws IOException
> * @throws SolrServerException
> */
> public static void indexFilesSolrCell(String fileName, String solrId)
> throws IOException, SolrServerException {
>
> String urlString = "http://localhost:8983/solr";
> SolrServer solr = new CommonsHttpSolrServer(urlString);
>
> ContentStreamUpdateRequest up
> = new ContentStreamUpdateRequest("/update/extract");
>
> up.addFile(new File(fileName));
>
> up.setParam("literal.id", solrId);
> up.setParam("uprefix", "attr_");
> up.setParam("fmap.content", "attr_content");
>
> up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
>
> solr.request(up);
>
> QueryResponse rsp = solr.query(new SolrQuery("*:*"));
>
> System.out.println(rsp);
> }
> }
>
> Thanks
Ufindthem <http://www.ufindthem.com>
--
View this message in context: http://lucene.472066.n3.nabble.com/error-Unsupported-Media-Type-while-implementing-ContentStreamUpdateRequestExample-from-the-link-httpe-tp4169035p4218516.html
Sent from the Apache Tika - Development mailing list archive at Nabble.com.
Re: error Unsupported Media Type : while implementing
ContentStreamUpdateRequestExample from the link http://wiki.apache.org/solr/ContentStreamUpdateRequestExample
Posted by Tyler Palsulich <tp...@gmail.com>.
Hi,
Thanks for raising this issue! Can you give a complete stacktrace with the
error? Are you able to run Tika by itself on the file? What is the returned
MediaType?
Thanks,
Tyler
On Thu, Nov 13, 2014 at 5:38 AM, raju <lo...@gmail.com> wrote:
> Hi Team,
>
> I am getting the error org.apache.solr.common.SolrException: Unsupported
> Media Type
>
> Unsupported Media Type
>
> I have used the code from
> http://wiki.apache.org/solr/ContentStreamUpdateRequestExample
>
> could some body help me, to me it is failing when it encounters the code
> solr.request(up);
>
> package javaapplicationsolrcell;
>
> import java.io.File;
> import java.io.IOException;
> import org.apache.solr.client.solrj.SolrServer;
> import org.apache.solr.client.solrj.SolrServerException;
>
> import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
> import org.apache.solr.client.solrj.response.QueryResponse;
> import org.apache.solr.client.solrj.SolrQuery;
> import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
> import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest;
>
> /**
> * @author EDaniel
> */
> public class SolrExampleTests {
>
> public static void main(String[] args) {
> try {
> //Solr cell can also index MS file (2003 version and 2007 version)
> types.
> String fileName = "c:/Sample.pdf";
> //this will be unique Id used by Solr to index the file contents.
> String solrId = "Sample.pdf";
>
> indexFilesSolrCell(fileName, solrId);
>
> } catch (Exception ex) {
> System.out.println(ex.toString());
> }
> }
>
> /**
> * Method to index all types of files into Solr.
> * @param fileName
> * @param solrId
> * @throws IOException
> * @throws SolrServerException
> */
> public static void indexFilesSolrCell(String fileName, String solrId)
> throws IOException, SolrServerException {
>
> String urlString = "http://localhost:8983/solr";
> SolrServer solr = new CommonsHttpSolrServer(urlString);
>
> ContentStreamUpdateRequest up
> = new ContentStreamUpdateRequest("/update/extract");
>
> up.addFile(new File(fileName));
>
> up.setParam("literal.id", solrId);
> up.setParam("uprefix", "attr_");
> up.setParam("fmap.content", "attr_content");
>
> up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
>
> solr.request(up);
>
> QueryResponse rsp = solr.query(new SolrQuery("*:*"));
>
> System.out.println(rsp);
> }
> }
>
> Thanks
> raju
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/error-Unsupported-Media-Type-while-implementing-ContentStreamUpdateRequestExample-from-the-link-httpe-tp4169035.html
> Sent from the Apache Tika - Development mailing list archive at Nabble.com.
>