Please answer my question on StackOverflow ... "Best approach to guarantee commits in SOLR"

2015-08-25 Thread Simer P
http://stackoverflow.com/questions/32138845/what-is-the-best-approach-to-guarantee-commits-in-apache-solr
.

*Question:* How can I get "guarantee commits" with Apache SOLR where
persisting data to disk and visibility are both equally important ?

*Background:* We have a website which requires high end search
functionality for machine learning and also requires guaranteed commit for
financial transaction. We just want to SOLR as our only datastore to keep
things simple and *do not* want to use another database on the side.

I can't seem to find any answer to this question. The simplest solution for
a financial transaction seems to be to periodically query SOLR for the
record after it has been persisted but this can have longer wait time or is
there a better solution ?

Can anyone please suggest a solution for achieving "guaranteed commits"
with SOLR ?


Re: Solr read timed out in client environment

2013-07-24 Thread Simer P
Sounds like this problem has to be on your client environment. Should check
if your client environment requires different authentication or if there is
a firewall that blocking your request.


On Wed, Jul 24, 2013 at 9:20 PM, bucci  wrote:

> Hello,
> we've got following error when we are trying to index(add) single document
> to our Knowledge Base project. It works fine on our test environment but
> with any attempt to add index in client environment it throws Read timeout
> error.
>
> When searching articles it's ok, problem occurs only at insert.
>
> Here's error:
>
> 2013-07-03 15:30:19,273 org.apache.solr.client.solrj.SolrServerException:
> /java.net.SocketTimeoutException: Read timed out
> at
>
> org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:480)
> at
>
> org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:246)
> at
>
> org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:105)
> at org.apache.solr.client.solrj.SolrServer.commit(SolrServer.java:178)
> at org.apache.solr.client.solrj.SolrServer.commit(SolrServer.java:154)/
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Solr-read-timed-out-in-client-environment-tp4079991.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>


DIGEST authentication with HttpSolrServer not working ... PLEASE HELPPPP !!!

2013-07-24 Thread Simer P
Hey Guys,

I was wondering if anyone has successfully been able to connect to SOLR
4.3.1 using DIGEST authentication with HttpSolrServer ?

*How I generated the password*
./digest.sh -a md5 admin:secure:password
admin:secure:password:e430caca84c337d4b820c44c1ebc943a

*I can successfully log in via browser:*
*[image: Inline image 1]
*
*
*
*Tomcat Logs after :*
FINE: Attempting to authenticate user "admin" with realm
"org.apache.catalina.realm.MemoryRealm/1.0"
Jul 24, 2013 7:32:49 PM org.apache.catalina.realm.RealmBase authenticate
FINE: Digest : d085a7ed1747cc5e44748e402f8bfea3 Username:admin
ClientSigest:d085a7ed1747cc5e44748e402f8bfea3
nonce:1374658345333:90ec031d23e72defdeef154de6819b12 nc:004f
cnonce:52545941c1d2299c qop:auth
realm:securemd5a2:ea8719b47592cd3b04329611320a94d9 Server
digest:d085a7ed1747cc5e44748e402f8bfea3
Jul 24, 2013 7:32:49 PM org.apache.catalina.realm.CombinedRealm authenticate
FINE: Authenticated user "admin" with realm
"org.apache.catalina.realm.MemoryRealm/1.0"
Jul 24, 2013 7:32:49 PM org.apache.catalina.realm.RealmBase
hasResourcePermission
FINE:   Checking roles GenericPrincipal[admin(admin,manager-script,)]
Jul 24, 2013 7:32:49 PM org.apache.catalina.realm.RealmBase hasRole
FINE: Username admin has role admin
Jul 24, 2013 7:32:49 PM org.apache.catalina.realm.RealmBase
hasResourcePermission
FINE: Role found:  admin

I can also successfully log in connecting using HttpClient directly doing a
HttpGet

HttpResponse response = *null*;
HttpHost targetHost = *new* HttpHost("localhost", 8080, "http");
DefaultHttpClient httpClient = *new* DefaultHttpClient();
AuthScope authScope = *new*
 AuthScope(targetHost.getHostName(), targetHost.getPort(), "secure");
UsernamePasswordCredentials credentials = *new* UsernamePasswordCredentials(
"admin", "password");
httpClient.getCredentialsProvider().setCredentials(authScope, credentials);
HttpGet httpget = *new* HttpGet("http://localhost:8080";);
response = httpClient.execute(targetHost, httpget);
System.out.println(response); //Which prints HTTP/1.1 200 OK [Server:
Apache-Coyote/1.1, Cache-Control: private, Expires: Thu, 01 Jan 1970
10:00:00 EST, Content-Type: text/html;charset=UTF-8, Transfer-Encoding:
chunked, Date: Wed, 24 Jul 2013 10:02:37 GMT]


Logs for the above connection:
FINE: Attempting to authenticate user "admin" with realm
"org.apache.catalina.realm.MemoryRealm/1.0"
Jul 24, 2013 7:35:52 PM org.apache.catalina.realm.RealmBase authenticate
FINE: Digest : 85e101cdfbb5585696b557fe55601077 Username:admin
ClientSigest:85e101cdfbb5585696b557fe55601077
nonce:1374658552710:00f1e255052b59840a73f6919d9ada78 nc:0001
cnonce:37d15b4cfe5167b4 qop:auth
realm:securemd5a2:71998c64aea37ae77020c49c00f73fa8 Server
digest:85e101cdfbb5585696b557fe55601077
Jul 24, 2013 7:35:52 PM org.apache.catalina.realm.CombinedRealm authenticate
FINE: Authenticated user "admin" with realm
"org.apache.catalina.realm.MemoryRealm/1.0"
Jul 24, 2013 7:35:52 PM org.apache.catalina.realm.RealmBase
hasResourcePermission
FINE:   Checking roles GenericPrincipal[admin(admin,manager-script,)]
Jul 24, 2013 7:35:52 PM org.apache.catalina.realm.RealmBase hasRole
FINE: Username admin has role admin
Jul 24, 2013 7:35:52 PM org.apache.catalina.realm.RealmBase
hasResourcePermission
FINE: Role found:  admin

*It's just that when I request using HttpSolrServer I get unauthorized error
*
org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException:
Server at 
http://localhost:8080/primary
returned non ok status:401, message:Unauthorized
*
*
Here is how I'm connecting to SOLR using HttpSolrServer

HttpResponse response = *null*;
HttpHost targetHost = *new* HttpHost("localhost", 8080, "http");
DefaultHttpClient httpClient = *new* DefaultHttpClient();
httpClient.addRequestInterceptor(*new* PreemptiveAuthInterceptor(), 0);
AuthScope authScope = *new*
 AuthScope(targetHost.getHostName(), targetHost.getPort(), "secure");
UsernamePasswordCredentials credentials = *new* UsernamePasswordCredentials(
"admin", "password");
httpClient.getCredentialsProvider().setCredentials(authScope, credentials);

HttpSolrServer primary = *new* HttpSolrServer("http://localhost:8080"; +
"\" + PRIMARY, httpClient);
primary.add(*new* SolrInputDocument(), 20);


And my Interceptor being

*public* *class* PreemptiveAuthInterceptor *implements*
 HttpRequestInterceptor {

*public* *void* process(HttpRequest hr, HttpContext context) *throws*
 HttpException, IOException {
AuthState authState = (AuthState)
context.getAttribute(ClientContext.TARGET_AUTH_STATE);
*if* (authState.getAuthScheme() == *null*) {
CredentialsProvider credsProvider = (CredentialsProvider)
context.getAttribute(ClientContext.CREDS_PROVIDER);
HttpHost targetHost = (HttpHost)
context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
AuthScope authScope = *new*
 AuthScope(targetHost.getHostName(), targetHost.getPort(), "secure");
cre