Re: can't make GET request to solr in android app

2014-05-05 Thread blach
thanks,

basically I'm running solr on my localhost(computer) and trying to access it
through the emulator in eclipse, NOT in the physical phone.

Can it be done?



--
View this message in context: 
http://lucene.472066.n3.nabble.com/can-t-make-GET-request-to-solr-in-android-app-tp4134584p4134706.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: can't make GET request to solr in android app

2014-05-05 Thread blach
Hi, 
It's not an error if you see my code, there is a catch statement, which
contains the FAIL message, it does always show it.





--
View this message in context: 
http://lucene.472066.n3.nabble.com/can-t-make-GET-request-to-solr-in-android-app-tp4134584p4134709.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: can't make GET request to solr in android app

2014-05-05 Thread Shawn Heisey
On 5/5/2014 9:02 AM, blach wrote:
 It's not an error if you see my code, there is a catch statement, which
 contains the FAIL message, it does always show it.

In your code, you are not printing the stack trace or throwing the
exception.  If you want to see it in your own code, you'll need to
include code to write out the stacktrace from the exception.  If you
don't want to do that, you can look on the server log to see what the
exception is.

Since you are basically writing Java code (I'm aware that Dalvik is not
*actually* Java, but I've never written code for android), can you use
SolrJ instead of HttpClient?

Thanks,
Shawn



Re: can't make GET request to solr in android app

2014-05-05 Thread blach
Yes Im reading about SOLRJ now

I wrote this code for it, but its the same problem, in this case all the app
is stopping, this is the code
 String urlString =
http://localhost:8983/solr;;
SolrServer solr = new HttpSolrServer(urlString);


SolrQuery query = new SolrQuery();
query.set(q, mem);
  
   QueryResponse response = null;

try {
response = 
solr.query(query);
} catch (SolrServerException e) 
{
// TODO Auto-generated 
catch block
e.printStackTrace();
}

SolrDocumentList results = 
response.getResults();
for (int i = 0; i  results.size(); ++i) {
  
etxt2.setText((CharSequence) 
results.get(i));
}




--
View this message in context: 
http://lucene.472066.n3.nabble.com/can-t-make-GET-request-to-solr-in-android-app-tp4134584p4134735.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: can't make GET request to solr in android app

2014-05-05 Thread Shawn Heisey
On 5/5/2014 11:05 AM, blach wrote:
 I wrote this code for it, but its the same problem, in this case all
 the app is stopping, this is the code String urlString =
 http://localhost:8983/solr;; SolrServer solr = new
 HttpSolrServer(urlString);

 SolrQuery query = new SolrQuery(); query.set(q, mem); 
 QueryResponse response = null;  try { response = solr.query(query); }
 catch (SolrServerException e) { // TODO Auto-generated catch block
 e.printStackTrace(); }  SolrDocumentList results =
 response.getResults(); for (int i = 0; i  results.size(); ++i) { 
 etxt2.setText((CharSequence) results.get(i)); }

Do you get any output to stderr?  Have you looked in the solr logfile to
see if there's an error logged there?

Note that you should add the core name to the URL -- using a path of
just /solr is deprecated in the newest Solr versions.

http://localhost:8983/solr/corename

Thanks,
Shawn



Re: can't make GET request to solr in android app

2014-05-05 Thread blach
Thank you Shawn 

I did what you told me. now this is my code:


import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
//import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;

import org.apache.solr.client.solrj.impl.*;

import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocumentList;


import java.io.InputStream;
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//etxt2.setText(etxt1.getText());
  
  //ALERT MESSAGE
 // Toast.makeText(getBaseContext(),Please wait, connecting to
server.,Toast.LENGTH_LONG).show(); 
SolrServer solr;
String urlString = 
http://localhost:8983/solr/collection1;;
solr = new HttpSolrServer(urlString);

SolrQuery query = new SolrQuery();
query.set(qt, /select);
query.set(q, mem);
  
   QueryResponse response = null;

try {
response = 
solr.query(query);
SolrDocumentList 
results = response.getResults();
for (int i = 0; i  
results.size(); ++i) {
  
//System.out.println(results.get(i));

etxt2.setText((CharSequence) results.get(i));
}
} catch (SolrServerException e) 
{
// TODO Auto-generated 
catch block
e.printStackTrace();
}
  }});   }




it gives me error that org.apache.solr.client.solrj is not found 




--
View this message in context: 
http://lucene.472066.n3.nabble.com/can-t-make-GET-request-to-solr-in-android-app-tp4134584p4134769.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: can't make GET request to solr in android app

2014-05-05 Thread Shawn Heisey
On 5/5/2014 12:17 PM, blach wrote:
 Thank you Shawn 

 I did what you told me. now this is my code:

snip

 it gives me error that org.apache.solr.client.solrj is not found 

I don't know how to do classpath management in the Android enviroment. 
You'll need to add the solrj jar to your application classpath.  In the
download that I have extracted on my computer, this is named
dist/solr-solrj-4.7.2.jar ... the version number is usually in the
filename.  A number of other jars are also required.  You can find these
in the dist/solrj-lib directory.  If you need a newer or slightly older
version of one of the dependent jars for your own code, it is usually OK
to use a slightly different version.

Thanks,
Shawn



Re: can't make GET request to solr in android app

2014-05-05 Thread blach
I have included the reference for this library in good way but still giving
me the same error.

feeling 



--
View this message in context: 
http://lucene.472066.n3.nabble.com/can-t-make-GET-request-to-solr-in-android-app-tp4134584p4134785.html
Sent from the Solr - User mailing list archive at Nabble.com.


can't make GET request to solr in android app

2014-05-04 Thread blach
Hello all.

I'm trying to make a small search engine based on android. when I'm calling
solr by this 
http://localhost:8983/solr/collection1/select?q=+loginValue+wt=jsonindent=true;;
(loginValue is the keywork im looking for)

Its always giving me a fail message this is the code:

 try{ 

// URLEncode user defined data

  String loginValue=
URLEncoder.encode(etxt1.getText().toString(), UTF-8);
   
  // Create http client object to send request to server

  HttpClient Client = new DefaultHttpClient();
  
  
   String URL =
http://localhost:8983/solr/collection1/select?q=+loginValue+wt=jsonindent=true;;
  

  try
   {
 String SetServerString = ;
   
   // Create Request to server and get response
HttpGet httpget = new HttpGet(URL);
ResponseHandlerString responseHandler = new
BasicResponseHandler();
SetServerString = Client.execute(httpget,
responseHandler);
  
 // Show response on activity 

etxt2.setText(SetServerString);
  

   
}}
  catch(Exception ex)
 {
  etxt2.setText(Fail!);
  }
   }
 catch(UnsupportedEncodingException ex)
  {
 etxt2.setText(Fail1);
   } 
   }





any suggestion 



--
View this message in context: 
http://lucene.472066.n3.nabble.com/can-t-make-GET-request-to-solr-in-android-app-tp4134584.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: can't make GET request to solr in android app

2014-05-04 Thread Alexandre Rafalovitch
Step back a bit here.

Did you manage to get Solr itself running on Android? I thought that
supposed to be not feasible!

You code seems to imply that you have, because you are connecting to localhost.

Alternatively - and more reasonably - if you have Solr running on the
server in the cloud, you need to provide THAT server's address instead
of localhost.

Regards,
   Alex.
Personal website: http://www.outerthoughts.com/
Current project: http://www.solr-start.com/ - Accelerating your Solr proficiency


On Mon, May 5, 2014 at 7:22 AM, blach stag...@gmail.com wrote:
 Hello all.

 I'm trying to make a small search engine based on android. when I'm calling
 solr by this
 http://localhost:8983/solr/collection1/select?q=+loginValue+wt=jsonindent=true;;
 (loginValue is the keywork im looking for)

 Its always giving me a fail message this is the code:

  try{

 // URLEncode user defined data

   String loginValue=
 URLEncoder.encode(etxt1.getText().toString(), UTF-8);

   // Create http client object to send request to server

   HttpClient Client = new DefaultHttpClient();


String URL =
 http://localhost:8983/solr/collection1/select?q=+loginValue+wt=jsonindent=true;;


   try
{
  String SetServerString = ;

// Create Request to server and get response
 HttpGet httpget = new HttpGet(URL);
 ResponseHandlerString responseHandler = new
 BasicResponseHandler();
 SetServerString = Client.execute(httpget,
 responseHandler);

  // Show response on activity

 etxt2.setText(SetServerString);



 }}
   catch(Exception ex)
  {
   etxt2.setText(Fail!);
   }
}
  catch(UnsupportedEncodingException ex)
   {
  etxt2.setText(Fail1);
}
}





 any suggestion



 --
 View this message in context: 
 http://lucene.472066.n3.nabble.com/can-t-make-GET-request-to-solr-in-android-app-tp4134584.html
 Sent from the Solr - User mailing list archive at Nabble.com.


Re: can't make GET request to solr in android app

2014-05-04 Thread Shawn Heisey
On 5/4/2014 6:22 PM, blach wrote:
 I'm trying to make a small search engine based on android. when I'm calling
 solr by this 
 http://localhost:8983/solr/collection1/select?q=+loginValue+wt=jsonindent=true;;
 (loginValue is the keywork im looking for)

Without seeing the error you're getting, we can't really help.  If there
is an error, it should be in the Solr log on the server, though it might
be in the log on the client too.

Can you use the SolrJ API in an android app instead of HttpClient?
SolrJ uses HttpClient to make connections.  I have no idea whether SolrJ
is compatible with Google's virtual machine.

https://cwiki.apache.org/confluence/display/solr/Using+SolrJ

NB: In order to get an android phone to talk to your Solr server, you
probably need to have it open to the Internet.  Leaving a Solr server
open to the Internet is generally a bad idea, unless you can put it
behind a proxy that recognizes and stops harmful requests.  Without a
well-programmed proxy, anyone who can reach that Solr server will be
able to harm it by deleting your index, changing your index, or sending
denial of service requests that will keep it busy.

Thanks,
Shawn