4 days and no solution - please help on Solr

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

4 days and no solution - please help on Solr

☼ R Nair
Dear all,

I have tried my best to do it - searched all Google. But I an=m
unsuccessful. Kindly help.

We have a solo environment. Its secured with userid and password.

I used
CloudSolrClient.Builder(solrURLs).withHttpClient(mycloseablehttpclient)
method to access it. The url is of the form http:/userid:password@/
passionbytes.com/solr. I set defaultCollectionName later.
In mycloseablehttpclient, I set Basic Authentication with
CredentialProvider and gave url, port, userid and password.
I have changed HTTPCLIENT to 4.4.1 version, even tried 4.5.3.

Still, I get the JSON response from server, saying the URL did not return
the state information from SOLR. It says HTTP 401 , Authentication Required.

This is fourth day on this problem. Any help is appreciated. I have done
whatever is available through documentation and/or Google.

Best,
Ravion
Reply | Threaded
Open this post in threaded view
|

Re: 4 days and no solution - please help on Solr

Jason Gerlowski
Hi Ravion,

(Note: I'm not sure what Solr version you're using.  My answer below
assumes Solr 7 APIs.  These APIs don't change often, but you might
find them under slightly different names in your version of Solr.)

SolrJ provides 2 ways (that I know of) to provide basic auth credentials.

The first (and IMO simplest) way is to use the setBasicAuthCredentials
method on each individual SolrRequest.  You can see what this looks
like in the example below:

final SolrClient client = new
CloudSolrCLient.Builder(solrURLs).withHttpClient(myHttpClient).build();
client.setDefaultCollection("collection1");
SolrQuery req = new SolrQuery("*:*");
req.setBasicAuthCredentials("yourUsername", "yourPassword);
client.query(req);

SolrJ also has a PreemptiveBasicAuthClientBuilderFactory, which reads
the username/password from Java system properties, and is used to
configure the HttpClient that SolrJ creates internally for sending
requests.  I find this second method a little more complex, and it
looks like you're providing your own HttpClient anyways, so for both
those reasons I'd recommend sticking with the first approach (at least
while you're getting things up and running).

Hope that helps.

Best,

Jason

On Thu, Aug 9, 2018 at 5:47 PM ☼ R Nair <[hidden email]> wrote:

>
> Dear all,
>
> I have tried my best to do it - searched all Google. But I an=m
> unsuccessful. Kindly help.
>
> We have a solo environment. Its secured with userid and password.
>
> I used
> CloudSolrClient.Builder(solrURLs).withHttpClient(mycloseablehttpclient)
> method to access it. The url is of the form http:/userid:password@/
> passionbytes.com/solr. I set defaultCollectionName later.
> In mycloseablehttpclient, I set Basic Authentication with
> CredentialProvider and gave url, port, userid and password.
> I have changed HTTPCLIENT to 4.4.1 version, even tried 4.5.3.
>
> Still, I get the JSON response from server, saying the URL did not return
> the state information from SOLR. It says HTTP 401 , Authentication Required.
>
> This is fourth day on this problem. Any help is appreciated. I have done
> whatever is available through documentation and/or Google.
>
> Best,
> Ravion
Reply | Threaded
Open this post in threaded view
|

Re: 4 days and no solution - please help on Solr

Jason Gerlowski
I would also recommend removing the username/password from your Solr
base URL.  You might be able to get things working that way, but it's
definitely less common, and it wouldn't surprise me if some parts of
SolrJ mishandle a URL in that format.  Though that's just a hunch on
my part.
On Fri, Aug 10, 2018 at 10:09 AM Jason Gerlowski <[hidden email]> wrote:

>
> Hi Ravion,
>
> (Note: I'm not sure what Solr version you're using.  My answer below
> assumes Solr 7 APIs.  These APIs don't change often, but you might
> find them under slightly different names in your version of Solr.)
>
> SolrJ provides 2 ways (that I know of) to provide basic auth credentials.
>
> The first (and IMO simplest) way is to use the setBasicAuthCredentials
> method on each individual SolrRequest.  You can see what this looks
> like in the example below:
>
> final SolrClient client = new
> CloudSolrCLient.Builder(solrURLs).withHttpClient(myHttpClient).build();
> client.setDefaultCollection("collection1");
> SolrQuery req = new SolrQuery("*:*");
> req.setBasicAuthCredentials("yourUsername", "yourPassword);
> client.query(req);
>
> SolrJ also has a PreemptiveBasicAuthClientBuilderFactory, which reads
> the username/password from Java system properties, and is used to
> configure the HttpClient that SolrJ creates internally for sending
> requests.  I find this second method a little more complex, and it
> looks like you're providing your own HttpClient anyways, so for both
> those reasons I'd recommend sticking with the first approach (at least
> while you're getting things up and running).
>
> Hope that helps.
>
> Best,
>
> Jason
>
> On Thu, Aug 9, 2018 at 5:47 PM ☼ R Nair <[hidden email]> wrote:
> >
> > Dear all,
> >
> > I have tried my best to do it - searched all Google. But I an=m
> > unsuccessful. Kindly help.
> >
> > We have a solo environment. Its secured with userid and password.
> >
> > I used
> > CloudSolrClient.Builder(solrURLs).withHttpClient(mycloseablehttpclient)
> > method to access it. The url is of the form http:/userid:password@/
> > passionbytes.com/solr. I set defaultCollectionName later.
> > In mycloseablehttpclient, I set Basic Authentication with
> > CredentialProvider and gave url, port, userid and password.
> > I have changed HTTPCLIENT to 4.4.1 version, even tried 4.5.3.
> >
> > Still, I get the JSON response from server, saying the URL did not return
> > the state information from SOLR. It says HTTP 401 , Authentication Required.
> >
> > This is fourth day on this problem. Any help is appreciated. I have done
> > whatever is available through documentation and/or Google.
> >
> > Best,
> > Ravion
Reply | Threaded
Open this post in threaded view
|

Re: 4 days and no solution - please help on Solr

Jason Gerlowski
I'd tried to type my previous SolrJ example snippet from memory.  That
didn't work out so great.  I've corrected it below:

final List<String> zkUrls = new ArrayList<>();
zkUrls.add("localhost:9983");
final SolrClient client = new CloudSolrClient.Builder(zkUrls,
Optional.empty()).build();

final Map<String, String> queryParamMap = new HashMap<String, String>();
queryParamMap.put("q", "*:*");
final QueryRequest query = new QueryRequest(new MapSolrParams(queryParamMap));
query.setBasicAuthCredentials("solr", "solrRocks");

query.process(client, "techproducts"); // or, client.request(query)
On Fri, Aug 10, 2018 at 10:12 AM Jason Gerlowski <[hidden email]> wrote:

>
> I would also recommend removing the username/password from your Solr
> base URL.  You might be able to get things working that way, but it's
> definitely less common, and it wouldn't surprise me if some parts of
> SolrJ mishandle a URL in that format.  Though that's just a hunch on
> my part.
> On Fri, Aug 10, 2018 at 10:09 AM Jason Gerlowski <[hidden email]> wrote:
> >
> > Hi Ravion,
> >
> > (Note: I'm not sure what Solr version you're using.  My answer below
> > assumes Solr 7 APIs.  These APIs don't change often, but you might
> > find them under slightly different names in your version of Solr.)
> >
> > SolrJ provides 2 ways (that I know of) to provide basic auth credentials.
> >
> > The first (and IMO simplest) way is to use the setBasicAuthCredentials
> > method on each individual SolrRequest.  You can see what this looks
> > like in the example below:
> >
> > final SolrClient client = new
> > CloudSolrCLient.Builder(solrURLs).withHttpClient(myHttpClient).build();
> > client.setDefaultCollection("collection1");
> > SolrQuery req = new SolrQuery("*:*");
> > req.setBasicAuthCredentials("yourUsername", "yourPassword);
> > client.query(req);
> >
> > SolrJ also has a PreemptiveBasicAuthClientBuilderFactory, which reads
> > the username/password from Java system properties, and is used to
> > configure the HttpClient that SolrJ creates internally for sending
> > requests.  I find this second method a little more complex, and it
> > looks like you're providing your own HttpClient anyways, so for both
> > those reasons I'd recommend sticking with the first approach (at least
> > while you're getting things up and running).
> >
> > Hope that helps.
> >
> > Best,
> >
> > Jason
> >
> > On Thu, Aug 9, 2018 at 5:47 PM ☼ R Nair <[hidden email]> wrote:
> > >
> > > Dear all,
> > >
> > > I have tried my best to do it - searched all Google. But I an=m
> > > unsuccessful. Kindly help.
> > >
> > > We have a solo environment. Its secured with userid and password.
> > >
> > > I used
> > > CloudSolrClient.Builder(solrURLs).withHttpClient(mycloseablehttpclient)
> > > method to access it. The url is of the form http:/userid:password@/
> > > passionbytes.com/solr. I set defaultCollectionName later.
> > > In mycloseablehttpclient, I set Basic Authentication with
> > > CredentialProvider and gave url, port, userid and password.
> > > I have changed HTTPCLIENT to 4.4.1 version, even tried 4.5.3.
> > >
> > > Still, I get the JSON response from server, saying the URL did not return
> > > the state information from SOLR. It says HTTP 401 , Authentication Required.
> > >
> > > This is fourth day on this problem. Any help is appreciated. I have done
> > > whatever is available through documentation and/or Google.
> > >
> > > Best,
> > > Ravion
Reply | Threaded
Open this post in threaded view
|

Re: 4 days and no solution - please help on Solr

☼ R Nair
Hi Jason,

Thanks for replying.

I am adding a document, not querying. I am using 7.3 apis. Adding a
document is done via solrclient.add(....). How to set authentication in
this case? Seems I can't use SolrRequest.

Thx, bye
RAVION

On Fri, Aug 10, 2018, 10:46 AM Jason Gerlowski <[hidden email]>
wrote:

> I'd tried to type my previous SolrJ example snippet from memory.  That
> didn't work out so great.  I've corrected it below:
>
> final List<String> zkUrls = new ArrayList<>();
> zkUrls.add("localhost:9983");
> final SolrClient client = new CloudSolrClient.Builder(zkUrls,
> Optional.empty()).build();
>
> final Map<String, String> queryParamMap = new HashMap<String, String>();
> queryParamMap.put("q", "*:*");
> final QueryRequest query = new QueryRequest(new
> MapSolrParams(queryParamMap));
> query.setBasicAuthCredentials("solr", "solrRocks");
>
> query.process(client, "techproducts"); // or, client.request(query)
> On Fri, Aug 10, 2018 at 10:12 AM Jason Gerlowski <[hidden email]>
> wrote:
> >
> > I would also recommend removing the username/password from your Solr
> > base URL.  You might be able to get things working that way, but it's
> > definitely less common, and it wouldn't surprise me if some parts of
> > SolrJ mishandle a URL in that format.  Though that's just a hunch on
> > my part.
> > On Fri, Aug 10, 2018 at 10:09 AM Jason Gerlowski <[hidden email]>
> wrote:
> > >
> > > Hi Ravion,
> > >
> > > (Note: I'm not sure what Solr version you're using.  My answer below
> > > assumes Solr 7 APIs.  These APIs don't change often, but you might
> > > find them under slightly different names in your version of Solr.)
> > >
> > > SolrJ provides 2 ways (that I know of) to provide basic auth
> credentials.
> > >
> > > The first (and IMO simplest) way is to use the setBasicAuthCredentials
> > > method on each individual SolrRequest.  You can see what this looks
> > > like in the example below:
> > >
> > > final SolrClient client = new
> > > CloudSolrCLient.Builder(solrURLs).withHttpClient(myHttpClient).build();
> > > client.setDefaultCollection("collection1");
> > > SolrQuery req = new SolrQuery("*:*");
> > > req.setBasicAuthCredentials("yourUsername", "yourPassword);
> > > client.query(req);
> > >
> > > SolrJ also has a PreemptiveBasicAuthClientBuilderFactory, which reads
> > > the username/password from Java system properties, and is used to
> > > configure the HttpClient that SolrJ creates internally for sending
> > > requests.  I find this second method a little more complex, and it
> > > looks like you're providing your own HttpClient anyways, so for both
> > > those reasons I'd recommend sticking with the first approach (at least
> > > while you're getting things up and running).
> > >
> > > Hope that helps.
> > >
> > > Best,
> > >
> > > Jason
> > >
> > > On Thu, Aug 9, 2018 at 5:47 PM ☼ R Nair <[hidden email]>
> wrote:
> > > >
> > > > Dear all,
> > > >
> > > > I have tried my best to do it - searched all Google. But I an=m
> > > > unsuccessful. Kindly help.
> > > >
> > > > We have a solo environment. Its secured with userid and password.
> > > >
> > > > I used
> > > >
> CloudSolrClient.Builder(solrURLs).withHttpClient(mycloseablehttpclient)
> > > > method to access it. The url is of the form http:/userid:password@/
> > > > passionbytes.com/solr. I set defaultCollectionName later.
> > > > In mycloseablehttpclient, I set Basic Authentication with
> > > > CredentialProvider and gave url, port, userid and password.
> > > > I have changed HTTPCLIENT to 4.4.1 version, even tried 4.5.3.
> > > >
> > > > Still, I get the JSON response from server, saying the URL did not
> return
> > > > the state information from SOLR. It says HTTP 401 , Authentication
> Required.
> > > >
> > > > This is fourth day on this problem. Any help is appreciated. I have
> done
> > > > whatever is available through documentation and/or Google.
> > > >
> > > > Best,
> > > > Ravion
>
Reply | Threaded
Open this post in threaded view
|

Re: 4 days and no solution - please help on Solr

Jason Gerlowski
The "setBasicAuthCredentials" method works on all SolrRequest
implementations.  There's a corresponding SolrRequest object for most
common Solr APIs.  As you mentioned, I used QueryRequest above, but
the same approach works for any SolrRequest object.

The specific one for indexing is "UpdateRequest".  Here's a short example below:

final List<SolrInputDocument> docsToIndex = new ArrayList<>();
...Prepare your docs for indexing....
final UpdateRequest update = new UpdateRequest();
update.add(docsToIndex);
update.setBasicAuthCredentials("solr", "solrRocks");
update.process(client, "techproducts");
On Fri, Aug 10, 2018 at 12:47 PM ☼ R Nair <[hidden email]> wrote:

>
> Hi Jason,
>
> Thanks for replying.
>
> I am adding a document, not querying. I am using 7.3 apis. Adding a
> document is done via solrclient.add(....). How to set authentication in
> this case? Seems I can't use SolrRequest.
>
> Thx, bye
> RAVION
>
> On Fri, Aug 10, 2018, 10:46 AM Jason Gerlowski <[hidden email]>
> wrote:
>
> > I'd tried to type my previous SolrJ example snippet from memory.  That
> > didn't work out so great.  I've corrected it below:
> >
> > final List<String> zkUrls = new ArrayList<>();
> > zkUrls.add("localhost:9983");
> > final SolrClient client = new CloudSolrClient.Builder(zkUrls,
> > Optional.empty()).build();
> >
> > final Map<String, String> queryParamMap = new HashMap<String, String>();
> > queryParamMap.put("q", "*:*");
> > final QueryRequest query = new QueryRequest(new
> > MapSolrParams(queryParamMap));
> > query.setBasicAuthCredentials("solr", "solrRocks");
> >
> > query.process(client, "techproducts"); // or, client.request(query)
> > On Fri, Aug 10, 2018 at 10:12 AM Jason Gerlowski <[hidden email]>
> > wrote:
> > >
> > > I would also recommend removing the username/password from your Solr
> > > base URL.  You might be able to get things working that way, but it's
> > > definitely less common, and it wouldn't surprise me if some parts of
> > > SolrJ mishandle a URL in that format.  Though that's just a hunch on
> > > my part.
> > > On Fri, Aug 10, 2018 at 10:09 AM Jason Gerlowski <[hidden email]>
> > wrote:
> > > >
> > > > Hi Ravion,
> > > >
> > > > (Note: I'm not sure what Solr version you're using.  My answer below
> > > > assumes Solr 7 APIs.  These APIs don't change often, but you might
> > > > find them under slightly different names in your version of Solr.)
> > > >
> > > > SolrJ provides 2 ways (that I know of) to provide basic auth
> > credentials.
> > > >
> > > > The first (and IMO simplest) way is to use the setBasicAuthCredentials
> > > > method on each individual SolrRequest.  You can see what this looks
> > > > like in the example below:
> > > >
> > > > final SolrClient client = new
> > > > CloudSolrCLient.Builder(solrURLs).withHttpClient(myHttpClient).build();
> > > > client.setDefaultCollection("collection1");
> > > > SolrQuery req = new SolrQuery("*:*");
> > > > req.setBasicAuthCredentials("yourUsername", "yourPassword);
> > > > client.query(req);
> > > >
> > > > SolrJ also has a PreemptiveBasicAuthClientBuilderFactory, which reads
> > > > the username/password from Java system properties, and is used to
> > > > configure the HttpClient that SolrJ creates internally for sending
> > > > requests.  I find this second method a little more complex, and it
> > > > looks like you're providing your own HttpClient anyways, so for both
> > > > those reasons I'd recommend sticking with the first approach (at least
> > > > while you're getting things up and running).
> > > >
> > > > Hope that helps.
> > > >
> > > > Best,
> > > >
> > > > Jason
> > > >
> > > > On Thu, Aug 9, 2018 at 5:47 PM ☼ R Nair <[hidden email]>
> > wrote:
> > > > >
> > > > > Dear all,
> > > > >
> > > > > I have tried my best to do it - searched all Google. But I an=m
> > > > > unsuccessful. Kindly help.
> > > > >
> > > > > We have a solo environment. Its secured with userid and password.
> > > > >
> > > > > I used
> > > > >
> > CloudSolrClient.Builder(solrURLs).withHttpClient(mycloseablehttpclient)
> > > > > method to access it. The url is of the form http:/userid:password@/
> > > > > passionbytes.com/solr. I set defaultCollectionName later.
> > > > > In mycloseablehttpclient, I set Basic Authentication with
> > > > > CredentialProvider and gave url, port, userid and password.
> > > > > I have changed HTTPCLIENT to 4.4.1 version, even tried 4.5.3.
> > > > >
> > > > > Still, I get the JSON response from server, saying the URL did not
> > return
> > > > > the state information from SOLR. It says HTTP 401 , Authentication
> > Required.
> > > > >
> > > > > This is fourth day on this problem. Any help is appreciated. I have
> > done
> > > > > whatever is available through documentation and/or Google.
> > > > >
> > > > > Best,
> > > > > Ravion
> >
Reply | Threaded
Open this post in threaded view
|

Re: 4 days and no solution - please help on Solr

☼ R Nair
I saw this. Please provide for add. My issue is with add. There is no
"AddRequesg". So how to do that, thanks

Best Ravion

On Fri, Aug 10, 2018, 12:58 PM Jason Gerlowski <[hidden email]>
wrote:

> The "setBasicAuthCredentials" method works on all SolrRequest
> implementations.  There's a corresponding SolrRequest object for most
> common Solr APIs.  As you mentioned, I used QueryRequest above, but
> the same approach works for any SolrRequest object.
>
> The specific one for indexing is "UpdateRequest".  Here's a short example
> below:
>
> final List<SolrInputDocument> docsToIndex = new ArrayList<>();
> ...Prepare your docs for indexing....
> final UpdateRequest update = new UpdateRequest();
> update.add(docsToIndex);
> update.setBasicAuthCredentials("solr", "solrRocks");
> update.process(client, "techproducts");
> On Fri, Aug 10, 2018 at 12:47 PM ☼ R Nair <[hidden email]>
> wrote:
> >
> > Hi Jason,
> >
> > Thanks for replying.
> >
> > I am adding a document, not querying. I am using 7.3 apis. Adding a
> > document is done via solrclient.add(....). How to set authentication in
> > this case? Seems I can't use SolrRequest.
> >
> > Thx, bye
> > RAVION
> >
> > On Fri, Aug 10, 2018, 10:46 AM Jason Gerlowski <[hidden email]>
> > wrote:
> >
> > > I'd tried to type my previous SolrJ example snippet from memory.  That
> > > didn't work out so great.  I've corrected it below:
> > >
> > > final List<String> zkUrls = new ArrayList<>();
> > > zkUrls.add("localhost:9983");
> > > final SolrClient client = new CloudSolrClient.Builder(zkUrls,
> > > Optional.empty()).build();
> > >
> > > final Map<String, String> queryParamMap = new HashMap<String,
> String>();
> > > queryParamMap.put("q", "*:*");
> > > final QueryRequest query = new QueryRequest(new
> > > MapSolrParams(queryParamMap));
> > > query.setBasicAuthCredentials("solr", "solrRocks");
> > >
> > > query.process(client, "techproducts"); // or, client.request(query)
> > > On Fri, Aug 10, 2018 at 10:12 AM Jason Gerlowski <
> [hidden email]>
> > > wrote:
> > > >
> > > > I would also recommend removing the username/password from your Solr
> > > > base URL.  You might be able to get things working that way, but it's
> > > > definitely less common, and it wouldn't surprise me if some parts of
> > > > SolrJ mishandle a URL in that format.  Though that's just a hunch on
> > > > my part.
> > > > On Fri, Aug 10, 2018 at 10:09 AM Jason Gerlowski <
> [hidden email]>
> > > wrote:
> > > > >
> > > > > Hi Ravion,
> > > > >
> > > > > (Note: I'm not sure what Solr version you're using.  My answer
> below
> > > > > assumes Solr 7 APIs.  These APIs don't change often, but you might
> > > > > find them under slightly different names in your version of Solr.)
> > > > >
> > > > > SolrJ provides 2 ways (that I know of) to provide basic auth
> > > credentials.
> > > > >
> > > > > The first (and IMO simplest) way is to use the
> setBasicAuthCredentials
> > > > > method on each individual SolrRequest.  You can see what this looks
> > > > > like in the example below:
> > > > >
> > > > > final SolrClient client = new
> > > > >
> CloudSolrCLient.Builder(solrURLs).withHttpClient(myHttpClient).build();
> > > > > client.setDefaultCollection("collection1");
> > > > > SolrQuery req = new SolrQuery("*:*");
> > > > > req.setBasicAuthCredentials("yourUsername", "yourPassword);
> > > > > client.query(req);
> > > > >
> > > > > SolrJ also has a PreemptiveBasicAuthClientBuilderFactory, which
> reads
> > > > > the username/password from Java system properties, and is used to
> > > > > configure the HttpClient that SolrJ creates internally for sending
> > > > > requests.  I find this second method a little more complex, and it
> > > > > looks like you're providing your own HttpClient anyways, so for
> both
> > > > > those reasons I'd recommend sticking with the first approach (at
> least
> > > > > while you're getting things up and running).
> > > > >
> > > > > Hope that helps.
> > > > >
> > > > > Best,
> > > > >
> > > > > Jason
> > > > >
> > > > > On Thu, Aug 9, 2018 at 5:47 PM ☼ R Nair <
> [hidden email]>
> > > wrote:
> > > > > >
> > > > > > Dear all,
> > > > > >
> > > > > > I have tried my best to do it - searched all Google. But I an=m
> > > > > > unsuccessful. Kindly help.
> > > > > >
> > > > > > We have a solo environment. Its secured with userid and password.
> > > > > >
> > > > > > I used
> > > > > >
> > > CloudSolrClient.Builder(solrURLs).withHttpClient(mycloseablehttpclient)
> > > > > > method to access it. The url is of the form
> http:/userid:password@/
> > > > > > passionbytes.com/solr. I set defaultCollectionName later.
> > > > > > In mycloseablehttpclient, I set Basic Authentication with
> > > > > > CredentialProvider and gave url, port, userid and password.
> > > > > > I have changed HTTPCLIENT to 4.4.1 version, even tried 4.5.3.
> > > > > >
> > > > > > Still, I get the JSON response from server, saying the URL did
> not
> > > return
> > > > > > the state information from SOLR. It says HTTP 401 ,
> Authentication
> > > Required.
> > > > > >
> > > > > > This is fourth day on this problem. Any help is appreciated. I
> have
> > > done
> > > > > > whatever is available through documentation and/or Google.
> > > > > >
> > > > > > Best,
> > > > > > Ravion
> > >
>
Reply | Threaded
Open this post in threaded view
|

Re: 4 days and no solution - please help on Solr

☼ R Nair
Do you feel that this is only partially complete?

Best, Ravion

On Fri, Aug 10, 2018, 1:37 PM ☼ R Nair <[hidden email]> wrote:

> I saw this. Please provide for add. My issue is with add. There is no
> "AddRequesg". So how to do that, thanks
>
> Best Ravion
>
> On Fri, Aug 10, 2018, 12:58 PM Jason Gerlowski <[hidden email]>
> wrote:
>
>> The "setBasicAuthCredentials" method works on all SolrRequest
>> implementations.  There's a corresponding SolrRequest object for most
>> common Solr APIs.  As you mentioned, I used QueryRequest above, but
>> the same approach works for any SolrRequest object.
>>
>> The specific one for indexing is "UpdateRequest".  Here's a short example
>> below:
>>
>> final List<SolrInputDocument> docsToIndex = new ArrayList<>();
>> ...Prepare your docs for indexing....
>> final UpdateRequest update = new UpdateRequest();
>> update.add(docsToIndex);
>> update.setBasicAuthCredentials("solr", "solrRocks");
>> update.process(client, "techproducts");
>> On Fri, Aug 10, 2018 at 12:47 PM ☼ R Nair <[hidden email]>
>> wrote:
>> >
>> > Hi Jason,
>> >
>> > Thanks for replying.
>> >
>> > I am adding a document, not querying. I am using 7.3 apis. Adding a
>> > document is done via solrclient.add(....). How to set authentication in
>> > this case? Seems I can't use SolrRequest.
>> >
>> > Thx, bye
>> > RAVION
>> >
>> > On Fri, Aug 10, 2018, 10:46 AM Jason Gerlowski <[hidden email]>
>> > wrote:
>> >
>> > > I'd tried to type my previous SolrJ example snippet from memory.  That
>> > > didn't work out so great.  I've corrected it below:
>> > >
>> > > final List<String> zkUrls = new ArrayList<>();
>> > > zkUrls.add("localhost:9983");
>> > > final SolrClient client = new CloudSolrClient.Builder(zkUrls,
>> > > Optional.empty()).build();
>> > >
>> > > final Map<String, String> queryParamMap = new HashMap<String,
>> String>();
>> > > queryParamMap.put("q", "*:*");
>> > > final QueryRequest query = new QueryRequest(new
>> > > MapSolrParams(queryParamMap));
>> > > query.setBasicAuthCredentials("solr", "solrRocks");
>> > >
>> > > query.process(client, "techproducts"); // or, client.request(query)
>> > > On Fri, Aug 10, 2018 at 10:12 AM Jason Gerlowski <
>> [hidden email]>
>> > > wrote:
>> > > >
>> > > > I would also recommend removing the username/password from your Solr
>> > > > base URL.  You might be able to get things working that way, but
>> it's
>> > > > definitely less common, and it wouldn't surprise me if some parts of
>> > > > SolrJ mishandle a URL in that format.  Though that's just a hunch on
>> > > > my part.
>> > > > On Fri, Aug 10, 2018 at 10:09 AM Jason Gerlowski <
>> [hidden email]>
>> > > wrote:
>> > > > >
>> > > > > Hi Ravion,
>> > > > >
>> > > > > (Note: I'm not sure what Solr version you're using.  My answer
>> below
>> > > > > assumes Solr 7 APIs.  These APIs don't change often, but you might
>> > > > > find them under slightly different names in your version of Solr.)
>> > > > >
>> > > > > SolrJ provides 2 ways (that I know of) to provide basic auth
>> > > credentials.
>> > > > >
>> > > > > The first (and IMO simplest) way is to use the
>> setBasicAuthCredentials
>> > > > > method on each individual SolrRequest.  You can see what this
>> looks
>> > > > > like in the example below:
>> > > > >
>> > > > > final SolrClient client = new
>> > > > >
>> CloudSolrCLient.Builder(solrURLs).withHttpClient(myHttpClient).build();
>> > > > > client.setDefaultCollection("collection1");
>> > > > > SolrQuery req = new SolrQuery("*:*");
>> > > > > req.setBasicAuthCredentials("yourUsername", "yourPassword);
>> > > > > client.query(req);
>> > > > >
>> > > > > SolrJ also has a PreemptiveBasicAuthClientBuilderFactory, which
>> reads
>> > > > > the username/password from Java system properties, and is used to
>> > > > > configure the HttpClient that SolrJ creates internally for sending
>> > > > > requests.  I find this second method a little more complex, and it
>> > > > > looks like you're providing your own HttpClient anyways, so for
>> both
>> > > > > those reasons I'd recommend sticking with the first approach (at
>> least
>> > > > > while you're getting things up and running).
>> > > > >
>> > > > > Hope that helps.
>> > > > >
>> > > > > Best,
>> > > > >
>> > > > > Jason
>> > > > >
>> > > > > On Thu, Aug 9, 2018 at 5:47 PM ☼ R Nair <
>> [hidden email]>
>> > > wrote:
>> > > > > >
>> > > > > > Dear all,
>> > > > > >
>> > > > > > I have tried my best to do it - searched all Google. But I an=m
>> > > > > > unsuccessful. Kindly help.
>> > > > > >
>> > > > > > We have a solo environment. Its secured with userid and
>> password.
>> > > > > >
>> > > > > > I used
>> > > > > >
>> > >
>> CloudSolrClient.Builder(solrURLs).withHttpClient(mycloseablehttpclient)
>> > > > > > method to access it. The url is of the form
>> http:/userid:password@/
>> > > > > > passionbytes.com/solr. I set defaultCollectionName later.
>> > > > > > In mycloseablehttpclient, I set Basic Authentication with
>> > > > > > CredentialProvider and gave url, port, userid and password.
>> > > > > > I have changed HTTPCLIENT to 4.4.1 version, even tried 4.5.3.
>> > > > > >
>> > > > > > Still, I get the JSON response from server, saying the URL did
>> not
>> > > return
>> > > > > > the state information from SOLR. It says HTTP 401 ,
>> Authentication
>> > > Required.
>> > > > > >
>> > > > > > This is fourth day on this problem. Any help is appreciated. I
>> have
>> > > done
>> > > > > > whatever is available through documentation and/or Google.
>> > > > > >
>> > > > > > Best,
>> > > > > > Ravion
>> > >
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: 4 days and no solution - please help on Solr

Christopher Schultz
Ravion,

What's wrong with "update request"? Updating a document that does not
exist... will add it.

-chris

On 8/10/18 3:01 PM, ☼ R Nair wrote:

> Do you feel that this is only partially complete?
>
> Best, Ravion
>
> On Fri, Aug 10, 2018, 1:37 PM ☼ R Nair <[hidden email]> wrote:
>
>> I saw this. Please provide for add. My issue is with add. There is no
>> "AddRequesg". So how to do that, thanks
>>
>> Best Ravion
>>
>> On Fri, Aug 10, 2018, 12:58 PM Jason Gerlowski <[hidden email]>
>> wrote:
>>
>>> The "setBasicAuthCredentials" method works on all SolrRequest
>>> implementations.  There's a corresponding SolrRequest object for most
>>> common Solr APIs.  As you mentioned, I used QueryRequest above, but
>>> the same approach works for any SolrRequest object.
>>>
>>> The specific one for indexing is "UpdateRequest".  Here's a short example
>>> below:
>>>
>>> final List<SolrInputDocument> docsToIndex = new ArrayList<>();
>>> ...Prepare your docs for indexing....
>>> final UpdateRequest update = new UpdateRequest();
>>> update.add(docsToIndex);
>>> update.setBasicAuthCredentials("solr", "solrRocks");
>>> update.process(client, "techproducts");
>>> On Fri, Aug 10, 2018 at 12:47 PM ☼ R Nair <[hidden email]>
>>> wrote:
>>>>
>>>> Hi Jason,
>>>>
>>>> Thanks for replying.
>>>>
>>>> I am adding a document, not querying. I am using 7.3 apis. Adding a
>>>> document is done via solrclient.add(....). How to set authentication in
>>>> this case? Seems I can't use SolrRequest.
>>>>
>>>> Thx, bye
>>>> RAVION
>>>>
>>>> On Fri, Aug 10, 2018, 10:46 AM Jason Gerlowski <[hidden email]>
>>>> wrote:
>>>>
>>>>> I'd tried to type my previous SolrJ example snippet from memory.  That
>>>>> didn't work out so great.  I've corrected it below:
>>>>>
>>>>> final List<String> zkUrls = new ArrayList<>();
>>>>> zkUrls.add("localhost:9983");
>>>>> final SolrClient client = new CloudSolrClient.Builder(zkUrls,
>>>>> Optional.empty()).build();
>>>>>
>>>>> final Map<String, String> queryParamMap = new HashMap<String,
>>> String>();
>>>>> queryParamMap.put("q", "*:*");
>>>>> final QueryRequest query = new QueryRequest(new
>>>>> MapSolrParams(queryParamMap));
>>>>> query.setBasicAuthCredentials("solr", "solrRocks");
>>>>>
>>>>> query.process(client, "techproducts"); // or, client.request(query)
>>>>> On Fri, Aug 10, 2018 at 10:12 AM Jason Gerlowski <
>>> [hidden email]>
>>>>> wrote:
>>>>>>
>>>>>> I would also recommend removing the username/password from your Solr
>>>>>> base URL.  You might be able to get things working that way, but
>>> it's
>>>>>> definitely less common, and it wouldn't surprise me if some parts of
>>>>>> SolrJ mishandle a URL in that format.  Though that's just a hunch on
>>>>>> my part.
>>>>>> On Fri, Aug 10, 2018 at 10:09 AM Jason Gerlowski <
>>> [hidden email]>
>>>>> wrote:
>>>>>>>
>>>>>>> Hi Ravion,
>>>>>>>
>>>>>>> (Note: I'm not sure what Solr version you're using.  My answer
>>> below
>>>>>>> assumes Solr 7 APIs.  These APIs don't change often, but you might
>>>>>>> find them under slightly different names in your version of Solr.)
>>>>>>>
>>>>>>> SolrJ provides 2 ways (that I know of) to provide basic auth
>>>>> credentials.
>>>>>>>
>>>>>>> The first (and IMO simplest) way is to use the
>>> setBasicAuthCredentials
>>>>>>> method on each individual SolrRequest.  You can see what this
>>> looks
>>>>>>> like in the example below:
>>>>>>>
>>>>>>> final SolrClient client = new
>>>>>>>
>>> CloudSolrCLient.Builder(solrURLs).withHttpClient(myHttpClient).build();
>>>>>>> client.setDefaultCollection("collection1");
>>>>>>> SolrQuery req = new SolrQuery("*:*");
>>>>>>> req.setBasicAuthCredentials("yourUsername", "yourPassword);
>>>>>>> client.query(req);
>>>>>>>
>>>>>>> SolrJ also has a PreemptiveBasicAuthClientBuilderFactory, which
>>> reads
>>>>>>> the username/password from Java system properties, and is used to
>>>>>>> configure the HttpClient that SolrJ creates internally for sending
>>>>>>> requests.  I find this second method a little more complex, and it
>>>>>>> looks like you're providing your own HttpClient anyways, so for
>>> both
>>>>>>> those reasons I'd recommend sticking with the first approach (at
>>> least
>>>>>>> while you're getting things up and running).
>>>>>>>
>>>>>>> Hope that helps.
>>>>>>>
>>>>>>> Best,
>>>>>>>
>>>>>>> Jason
>>>>>>>
>>>>>>> On Thu, Aug 9, 2018 at 5:47 PM ☼ R Nair <
>>> [hidden email]>
>>>>> wrote:
>>>>>>>>
>>>>>>>> Dear all,
>>>>>>>>
>>>>>>>> I have tried my best to do it - searched all Google. But I an=m
>>>>>>>> unsuccessful. Kindly help.
>>>>>>>>
>>>>>>>> We have a solo environment. Its secured with userid and
>>> password.
>>>>>>>>
>>>>>>>> I used
>>>>>>>>
>>>>>
>>> CloudSolrClient.Builder(solrURLs).withHttpClient(mycloseablehttpclient)
>>>>>>>> method to access it. The url is of the form
>>> http:/userid:password@/
>>>>>>>> passionbytes.com/solr. I set defaultCollectionName later.
>>>>>>>> In mycloseablehttpclient, I set Basic Authentication with
>>>>>>>> CredentialProvider and gave url, port, userid and password.
>>>>>>>> I have changed HTTPCLIENT to 4.4.1 version, even tried 4.5.3.
>>>>>>>>
>>>>>>>> Still, I get the JSON response from server, saying the URL did
>>> not
>>>>> return
>>>>>>>> the state information from SOLR. It says HTTP 401 ,
>>> Authentication
>>>>> Required.
>>>>>>>>
>>>>>>>> This is fourth day on this problem. Any help is appreciated. I
>>> have
>>>>> done
>>>>>>>> whatever is available through documentation and/or Google.
>>>>>>>>
>>>>>>>> Best,
>>>>>>>> Ravion
>>>>>
>>>
>>
>


signature.asc (957 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: 4 days and no solution - please help on Solr

☼ R Nair
Thanks Christoper and Jason. Problem solved. What you mentioned works.

Thanks a million. Have a good weekend.

Best,
Ravion

On Fri, Aug 10, 2018 at 3:31 PM Christopher Schultz <
[hidden email]> wrote:

> Ravion,
>
> What's wrong with "update request"? Updating a document that does not
> exist... will add it.
>
> -chris
>
> On 8/10/18 3:01 PM, ☼ R Nair wrote:
> > Do you feel that this is only partially complete?
> >
> > Best, Ravion
> >
> > On Fri, Aug 10, 2018, 1:37 PM ☼ R Nair <[hidden email]>
> wrote:
> >
> >> I saw this. Please provide for add. My issue is with add. There is no
> >> "AddRequesg". So how to do that, thanks
> >>
> >> Best Ravion
> >>
> >> On Fri, Aug 10, 2018, 12:58 PM Jason Gerlowski <[hidden email]>
> >> wrote:
> >>
> >>> The "setBasicAuthCredentials" method works on all SolrRequest
> >>> implementations.  There's a corresponding SolrRequest object for most
> >>> common Solr APIs.  As you mentioned, I used QueryRequest above, but
> >>> the same approach works for any SolrRequest object.
> >>>
> >>> The specific one for indexing is "UpdateRequest".  Here's a short
> example
> >>> below:
> >>>
> >>> final List<SolrInputDocument> docsToIndex = new ArrayList<>();
> >>> ...Prepare your docs for indexing....
> >>> final UpdateRequest update = new UpdateRequest();
> >>> update.add(docsToIndex);
> >>> update.setBasicAuthCredentials("solr", "solrRocks");
> >>> update.process(client, "techproducts");
> >>> On Fri, Aug 10, 2018 at 12:47 PM ☼ R Nair <[hidden email]>
> >>> wrote:
> >>>>
> >>>> Hi Jason,
> >>>>
> >>>> Thanks for replying.
> >>>>
> >>>> I am adding a document, not querying. I am using 7.3 apis. Adding a
> >>>> document is done via solrclient.add(....). How to set authentication
> in
> >>>> this case? Seems I can't use SolrRequest.
> >>>>
> >>>> Thx, bye
> >>>> RAVION
> >>>>
> >>>> On Fri, Aug 10, 2018, 10:46 AM Jason Gerlowski <[hidden email]
> >
> >>>> wrote:
> >>>>
> >>>>> I'd tried to type my previous SolrJ example snippet from memory.
> That
> >>>>> didn't work out so great.  I've corrected it below:
> >>>>>
> >>>>> final List<String> zkUrls = new ArrayList<>();
> >>>>> zkUrls.add("localhost:9983");
> >>>>> final SolrClient client = new CloudSolrClient.Builder(zkUrls,
> >>>>> Optional.empty()).build();
> >>>>>
> >>>>> final Map<String, String> queryParamMap = new HashMap<String,
> >>> String>();
> >>>>> queryParamMap.put("q", "*:*");
> >>>>> final QueryRequest query = new QueryRequest(new
> >>>>> MapSolrParams(queryParamMap));
> >>>>> query.setBasicAuthCredentials("solr", "solrRocks");
> >>>>>
> >>>>> query.process(client, "techproducts"); // or, client.request(query)
> >>>>> On Fri, Aug 10, 2018 at 10:12 AM Jason Gerlowski <
> >>> [hidden email]>
> >>>>> wrote:
> >>>>>>
> >>>>>> I would also recommend removing the username/password from your Solr
> >>>>>> base URL.  You might be able to get things working that way, but
> >>> it's
> >>>>>> definitely less common, and it wouldn't surprise me if some parts of
> >>>>>> SolrJ mishandle a URL in that format.  Though that's just a hunch on
> >>>>>> my part.
> >>>>>> On Fri, Aug 10, 2018 at 10:09 AM Jason Gerlowski <
> >>> [hidden email]>
> >>>>> wrote:
> >>>>>>>
> >>>>>>> Hi Ravion,
> >>>>>>>
> >>>>>>> (Note: I'm not sure what Solr version you're using.  My answer
> >>> below
> >>>>>>> assumes Solr 7 APIs.  These APIs don't change often, but you might
> >>>>>>> find them under slightly different names in your version of Solr.)
> >>>>>>>
> >>>>>>> SolrJ provides 2 ways (that I know of) to provide basic auth
> >>>>> credentials.
> >>>>>>>
> >>>>>>> The first (and IMO simplest) way is to use the
> >>> setBasicAuthCredentials
> >>>>>>> method on each individual SolrRequest.  You can see what this
> >>> looks
> >>>>>>> like in the example below:
> >>>>>>>
> >>>>>>> final SolrClient client = new
> >>>>>>>
> >>> CloudSolrCLient.Builder(solrURLs).withHttpClient(myHttpClient).build();
> >>>>>>> client.setDefaultCollection("collection1");
> >>>>>>> SolrQuery req = new SolrQuery("*:*");
> >>>>>>> req.setBasicAuthCredentials("yourUsername", "yourPassword);
> >>>>>>> client.query(req);
> >>>>>>>
> >>>>>>> SolrJ also has a PreemptiveBasicAuthClientBuilderFactory, which
> >>> reads
> >>>>>>> the username/password from Java system properties, and is used to
> >>>>>>> configure the HttpClient that SolrJ creates internally for sending
> >>>>>>> requests.  I find this second method a little more complex, and it
> >>>>>>> looks like you're providing your own HttpClient anyways, so for
> >>> both
> >>>>>>> those reasons I'd recommend sticking with the first approach (at
> >>> least
> >>>>>>> while you're getting things up and running).
> >>>>>>>
> >>>>>>> Hope that helps.
> >>>>>>>
> >>>>>>> Best,
> >>>>>>>
> >>>>>>> Jason
> >>>>>>>
> >>>>>>> On Thu, Aug 9, 2018 at 5:47 PM ☼ R Nair <
> >>> [hidden email]>
> >>>>> wrote:
> >>>>>>>>
> >>>>>>>> Dear all,
> >>>>>>>>
> >>>>>>>> I have tried my best to do it - searched all Google. But I an=m
> >>>>>>>> unsuccessful. Kindly help.
> >>>>>>>>
> >>>>>>>> We have a solo environment. Its secured with userid and
> >>> password.
> >>>>>>>>
> >>>>>>>> I used
> >>>>>>>>
> >>>>>
> >>> CloudSolrClient.Builder(solrURLs).withHttpClient(mycloseablehttpclient)
> >>>>>>>> method to access it. The url is of the form
> >>> http:/userid:password@/
> >>>>>>>> passionbytes.com/solr. I set defaultCollectionName later.
> >>>>>>>> In mycloseablehttpclient, I set Basic Authentication with
> >>>>>>>> CredentialProvider and gave url, port, userid and password.
> >>>>>>>> I have changed HTTPCLIENT to 4.4.1 version, even tried 4.5.3.
> >>>>>>>>
> >>>>>>>> Still, I get the JSON response from server, saying the URL did
> >>> not
> >>>>> return
> >>>>>>>> the state information from SOLR. It says HTTP 401 ,
> >>> Authentication
> >>>>> Required.
> >>>>>>>>
> >>>>>>>> This is fourth day on this problem. Any help is appreciated. I
> >>> have
> >>>>> done
> >>>>>>>> whatever is available through documentation and/or Google.
> >>>>>>>>
> >>>>>>>> Best,
> >>>>>>>> Ravion
> >>>>>
> >>>
> >>
> >
>
>
Reply | Threaded
Open this post in threaded view
|

Re: 4 days and no solution - please help on Solr

Jason Gerlowski
You're right that "Update" is a little misleading as a name.

Solr uses that term across the board to refer to new or updated docs.
The "add-documents" API is /solr/collection_name/update and is
implemented by "UpdateRequestHandlers".  You can configure Solr to
massage documents before indexing with a "UpdateRequestDocumentChain".
etc.

So the name is misleading, but at least it's consistent.

Best,

Jason
On Fri, Aug 10, 2018 at 10:52 PM ☼ R Nair <[hidden email]> wrote:

>
> Thanks Christoper and Jason. Problem solved. What you mentioned works.
>
> Thanks a million. Have a good weekend.
>
> Best,
> Ravion
>
> On Fri, Aug 10, 2018 at 3:31 PM Christopher Schultz <
> [hidden email]> wrote:
>
> > Ravion,
> >
> > What's wrong with "update request"? Updating a document that does not
> > exist... will add it.
> >
> > -chris
> >
> > On 8/10/18 3:01 PM, ☼ R Nair wrote:
> > > Do you feel that this is only partially complete?
> > >
> > > Best, Ravion
> > >
> > > On Fri, Aug 10, 2018, 1:37 PM ☼ R Nair <[hidden email]>
> > wrote:
> > >
> > >> I saw this. Please provide for add. My issue is with add. There is no
> > >> "AddRequesg". So how to do that, thanks
> > >>
> > >> Best Ravion
> > >>
> > >> On Fri, Aug 10, 2018, 12:58 PM Jason Gerlowski <[hidden email]>
> > >> wrote:
> > >>
> > >>> The "setBasicAuthCredentials" method works on all SolrRequest
> > >>> implementations.  There's a corresponding SolrRequest object for most
> > >>> common Solr APIs.  As you mentioned, I used QueryRequest above, but
> > >>> the same approach works for any SolrRequest object.
> > >>>
> > >>> The specific one for indexing is "UpdateRequest".  Here's a short
> > example
> > >>> below:
> > >>>
> > >>> final List<SolrInputDocument> docsToIndex = new ArrayList<>();
> > >>> ...Prepare your docs for indexing....
> > >>> final UpdateRequest update = new UpdateRequest();
> > >>> update.add(docsToIndex);
> > >>> update.setBasicAuthCredentials("solr", "solrRocks");
> > >>> update.process(client, "techproducts");
> > >>> On Fri, Aug 10, 2018 at 12:47 PM ☼ R Nair <[hidden email]>
> > >>> wrote:
> > >>>>
> > >>>> Hi Jason,
> > >>>>
> > >>>> Thanks for replying.
> > >>>>
> > >>>> I am adding a document, not querying. I am using 7.3 apis. Adding a
> > >>>> document is done via solrclient.add(....). How to set authentication
> > in
> > >>>> this case? Seems I can't use SolrRequest.
> > >>>>
> > >>>> Thx, bye
> > >>>> RAVION
> > >>>>
> > >>>> On Fri, Aug 10, 2018, 10:46 AM Jason Gerlowski <[hidden email]
> > >
> > >>>> wrote:
> > >>>>
> > >>>>> I'd tried to type my previous SolrJ example snippet from memory.
> > That
> > >>>>> didn't work out so great.  I've corrected it below:
> > >>>>>
> > >>>>> final List<String> zkUrls = new ArrayList<>();
> > >>>>> zkUrls.add("localhost:9983");
> > >>>>> final SolrClient client = new CloudSolrClient.Builder(zkUrls,
> > >>>>> Optional.empty()).build();
> > >>>>>
> > >>>>> final Map<String, String> queryParamMap = new HashMap<String,
> > >>> String>();
> > >>>>> queryParamMap.put("q", "*:*");
> > >>>>> final QueryRequest query = new QueryRequest(new
> > >>>>> MapSolrParams(queryParamMap));
> > >>>>> query.setBasicAuthCredentials("solr", "solrRocks");
> > >>>>>
> > >>>>> query.process(client, "techproducts"); // or, client.request(query)
> > >>>>> On Fri, Aug 10, 2018 at 10:12 AM Jason Gerlowski <
> > >>> [hidden email]>
> > >>>>> wrote:
> > >>>>>>
> > >>>>>> I would also recommend removing the username/password from your Solr
> > >>>>>> base URL.  You might be able to get things working that way, but
> > >>> it's
> > >>>>>> definitely less common, and it wouldn't surprise me if some parts of
> > >>>>>> SolrJ mishandle a URL in that format.  Though that's just a hunch on
> > >>>>>> my part.
> > >>>>>> On Fri, Aug 10, 2018 at 10:09 AM Jason Gerlowski <
> > >>> [hidden email]>
> > >>>>> wrote:
> > >>>>>>>
> > >>>>>>> Hi Ravion,
> > >>>>>>>
> > >>>>>>> (Note: I'm not sure what Solr version you're using.  My answer
> > >>> below
> > >>>>>>> assumes Solr 7 APIs.  These APIs don't change often, but you might
> > >>>>>>> find them under slightly different names in your version of Solr.)
> > >>>>>>>
> > >>>>>>> SolrJ provides 2 ways (that I know of) to provide basic auth
> > >>>>> credentials.
> > >>>>>>>
> > >>>>>>> The first (and IMO simplest) way is to use the
> > >>> setBasicAuthCredentials
> > >>>>>>> method on each individual SolrRequest.  You can see what this
> > >>> looks
> > >>>>>>> like in the example below:
> > >>>>>>>
> > >>>>>>> final SolrClient client = new
> > >>>>>>>
> > >>> CloudSolrCLient.Builder(solrURLs).withHttpClient(myHttpClient).build();
> > >>>>>>> client.setDefaultCollection("collection1");
> > >>>>>>> SolrQuery req = new SolrQuery("*:*");
> > >>>>>>> req.setBasicAuthCredentials("yourUsername", "yourPassword);
> > >>>>>>> client.query(req);
> > >>>>>>>
> > >>>>>>> SolrJ also has a PreemptiveBasicAuthClientBuilderFactory, which
> > >>> reads
> > >>>>>>> the username/password from Java system properties, and is used to
> > >>>>>>> configure the HttpClient that SolrJ creates internally for sending
> > >>>>>>> requests.  I find this second method a little more complex, and it
> > >>>>>>> looks like you're providing your own HttpClient anyways, so for
> > >>> both
> > >>>>>>> those reasons I'd recommend sticking with the first approach (at
> > >>> least
> > >>>>>>> while you're getting things up and running).
> > >>>>>>>
> > >>>>>>> Hope that helps.
> > >>>>>>>
> > >>>>>>> Best,
> > >>>>>>>
> > >>>>>>> Jason
> > >>>>>>>
> > >>>>>>> On Thu, Aug 9, 2018 at 5:47 PM ☼ R Nair <
> > >>> [hidden email]>
> > >>>>> wrote:
> > >>>>>>>>
> > >>>>>>>> Dear all,
> > >>>>>>>>
> > >>>>>>>> I have tried my best to do it - searched all Google. But I an=m
> > >>>>>>>> unsuccessful. Kindly help.
> > >>>>>>>>
> > >>>>>>>> We have a solo environment. Its secured with userid and
> > >>> password.
> > >>>>>>>>
> > >>>>>>>> I used
> > >>>>>>>>
> > >>>>>
> > >>> CloudSolrClient.Builder(solrURLs).withHttpClient(mycloseablehttpclient)
> > >>>>>>>> method to access it. The url is of the form
> > >>> http:/userid:password@/
> > >>>>>>>> passionbytes.com/solr. I set defaultCollectionName later.
> > >>>>>>>> In mycloseablehttpclient, I set Basic Authentication with
> > >>>>>>>> CredentialProvider and gave url, port, userid and password.
> > >>>>>>>> I have changed HTTPCLIENT to 4.4.1 version, even tried 4.5.3.
> > >>>>>>>>
> > >>>>>>>> Still, I get the JSON response from server, saying the URL did
> > >>> not
> > >>>>> return
> > >>>>>>>> the state information from SOLR. It says HTTP 401 ,
> > >>> Authentication
> > >>>>> Required.
> > >>>>>>>>
> > >>>>>>>> This is fourth day on this problem. Any help is appreciated. I
> > >>> have
> > >>>>> done
> > >>>>>>>> whatever is available through documentation and/or Google.
> > >>>>>>>>
> > >>>>>>>> Best,
> > >>>>>>>> Ravion
> > >>>>>
> > >>>
> > >>
> > >
> >
> >