You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Chris A. Mattmann (JIRA)" <ji...@apache.org> on 2010/08/23 16:27:18 UTC

[jira] Created: (SOLR-2079) Expose HttpServletRequest object from SolrQueryRequest object

Expose HttpServletRequest object from SolrQueryRequest object
-------------------------------------------------------------

                 Key: SOLR-2079
                 URL: https://issues.apache.org/jira/browse/SOLR-2079
             Project: Solr
          Issue Type: Improvement
          Components: Response Writers, search
            Reporter: Chris A. Mattmann
             Fix For: 3.1


This patch adds the HttpServletRequest object to the SolrQueryRequest object. The HttpServletRequest object is needed to obtain the client's IP address for geotargetting, and is part of the patches from W. Quach and C. Mattmann.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] Commented: (SOLR-2079) Expose HttpServletRequest object from SolrQueryRequest object

Posted by "Chris A. Mattmann (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SOLR-2079?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12901434#action_12901434 ] 

Chris A. Mattmann commented on SOLR-2079:
-----------------------------------------

Hey Guys: yep, whatever is the easiest way is fine with me. We just need the IP address so that we can do Geotargetting based on the host IP. This is part of the slew of patches that William and I put together. This is the way we saw it and it works but not the only way to do it, for sure!

> Expose HttpServletRequest object from SolrQueryRequest object
> -------------------------------------------------------------
>
>                 Key: SOLR-2079
>                 URL: https://issues.apache.org/jira/browse/SOLR-2079
>             Project: Solr
>          Issue Type: Improvement
>          Components: Response Writers, search
>            Reporter: Chris A. Mattmann
>             Fix For: 3.1
>
>         Attachments: SOLR-2079.Quach.Mattmann.082310.patch.txt
>
>
> This patch adds the HttpServletRequest object to the SolrQueryRequest object. The HttpServletRequest object is needed to obtain the client's IP address for geotargetting, and is part of the patches from W. Quach and C. Mattmann.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] Commented: (SOLR-2079) Expose HttpServletRequest object from SolrQueryRequest object

Posted by "Ryan McKinley (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SOLR-2079?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12901430#action_12901430 ] 

Ryan McKinley commented on SOLR-2079:
-------------------------------------

Ah yes -- i remember wanting to do this a long time ago.

Hoss convinced me that it really is not a good idea -- SolrQueryRequest is intentionally abstracted from HttpServletRequest -- adding it directly explodes the various ways things could be passed around.   

In my own code I subclass SolrDispatchFilter and attach whatever we need there:

{code:java}
@Override
  protected final void execute( HttpServletRequest req, SolrRequestHandler handler, SolrQueryRequest sreq, SolrQueryResponse rsp)
  {    
    sreq.getContext().put( "IP", req.getRemoteAddr() );
    super.execute(req, handler, sreq, rsp);
  }
{code}



> Expose HttpServletRequest object from SolrQueryRequest object
> -------------------------------------------------------------
>
>                 Key: SOLR-2079
>                 URL: https://issues.apache.org/jira/browse/SOLR-2079
>             Project: Solr
>          Issue Type: Improvement
>          Components: Response Writers, search
>            Reporter: Chris A. Mattmann
>             Fix For: 3.1
>
>         Attachments: SOLR-2079.Quach.Mattmann.082310.patch.txt
>
>
> This patch adds the HttpServletRequest object to the SolrQueryRequest object. The HttpServletRequest object is needed to obtain the client's IP address for geotargetting, and is part of the patches from W. Quach and C. Mattmann.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] Updated: (SOLR-2079) Expose HttpServletRequest object from SolrQueryRequest object

Posted by "Chris A. Mattmann (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SOLR-2079?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chris A. Mattmann updated SOLR-2079:
------------------------------------

    Attachment: SOLR-2079.Quach.Mattmann.082310.patch.txt

> Expose HttpServletRequest object from SolrQueryRequest object
> -------------------------------------------------------------
>
>                 Key: SOLR-2079
>                 URL: https://issues.apache.org/jira/browse/SOLR-2079
>             Project: Solr
>          Issue Type: Improvement
>          Components: Response Writers, search
>            Reporter: Chris A. Mattmann
>             Fix For: 3.1
>
>         Attachments: SOLR-2079.Quach.Mattmann.082310.patch.txt
>
>
> This patch adds the HttpServletRequest object to the SolrQueryRequest object. The HttpServletRequest object is needed to obtain the client's IP address for geotargetting, and is part of the patches from W. Quach and C. Mattmann.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] Commented: (SOLR-2079) Expose HttpServletRequest object from SolrQueryRequest object

Posted by "Lance Norskog (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SOLR-2079?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12903789#action_12903789 ] 

Lance Norskog commented on SOLR-2079:
-------------------------------------

+1 on Chris' comments. 

Personally, I would keep it as it is.  To keep the camel out of the tent, start with the camel's nose. 


> Expose HttpServletRequest object from SolrQueryRequest object
> -------------------------------------------------------------
>
>                 Key: SOLR-2079
>                 URL: https://issues.apache.org/jira/browse/SOLR-2079
>             Project: Solr
>          Issue Type: Improvement
>          Components: Response Writers, search
>            Reporter: Chris A. Mattmann
>             Fix For: 3.1
>
>         Attachments: SOLR-2079.Quach.Mattmann.082310.patch.txt
>
>
> This patch adds the HttpServletRequest object to the SolrQueryRequest object. The HttpServletRequest object is needed to obtain the client's IP address for geotargetting, and is part of the patches from W. Quach and C. Mattmann.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] Commented: (SOLR-2079) Expose HttpServletRequest object from SolrQueryRequest object

Posted by "Andrzej Bialecki (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SOLR-2079?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12901439#action_12901439 ] 

Andrzej Bialecki  commented on SOLR-2079:
-----------------------------------------

The IP may be often that of a load balancer or proxy that sits in front of Solr...

> Expose HttpServletRequest object from SolrQueryRequest object
> -------------------------------------------------------------
>
>                 Key: SOLR-2079
>                 URL: https://issues.apache.org/jira/browse/SOLR-2079
>             Project: Solr
>          Issue Type: Improvement
>          Components: Response Writers, search
>            Reporter: Chris A. Mattmann
>             Fix For: 3.1
>
>         Attachments: SOLR-2079.Quach.Mattmann.082310.patch.txt
>
>
> This patch adds the HttpServletRequest object to the SolrQueryRequest object. The HttpServletRequest object is needed to obtain the client's IP address for geotargetting, and is part of the patches from W. Quach and C. Mattmann.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] Commented: (SOLR-2079) Expose HttpServletRequest object from SolrQueryRequest object

Posted by "Simon Willnauer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SOLR-2079?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12901431#action_12901431 ] 

Simon Willnauer commented on SOLR-2079:
---------------------------------------

chris, wouldn't it be enough to expose the clients address which is less bound to a servlet than exposing the servlet request. Many users might use solr via their own protocols which are not necessarily exposed via Servlets. If you have code depending on the accessing the HttpServletRequest some people might run into problems. As far as I can see from your description you only need to expose the InetAddress right?

> Expose HttpServletRequest object from SolrQueryRequest object
> -------------------------------------------------------------
>
>                 Key: SOLR-2079
>                 URL: https://issues.apache.org/jira/browse/SOLR-2079
>             Project: Solr
>          Issue Type: Improvement
>          Components: Response Writers, search
>            Reporter: Chris A. Mattmann
>             Fix For: 3.1
>
>         Attachments: SOLR-2079.Quach.Mattmann.082310.patch.txt
>
>
> This patch adds the HttpServletRequest object to the SolrQueryRequest object. The HttpServletRequest object is needed to obtain the client's IP address for geotargetting, and is part of the patches from W. Quach and C. Mattmann.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] Commented: (SOLR-2079) Expose HttpServletRequest object from SolrQueryRequest object

Posted by "Hoss Man (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SOLR-2079?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12901546#action_12901546 ] 

Hoss Man commented on SOLR-2079:
--------------------------------

I'm really torn on stuff like this -- as Ryan mentioned, i think it's important to keep Solr abstract from HTTP so we don't wind up with functionality that *requires* the use of HTTP -- but on the other hand things like the API allowing RequestHandlers to specify when/if to allow HTTP Caching are kind of important, so we made special hooks for it

I'm not 100% opposed to SolrDispatchFilter adding the HttpServletRequest into the SolrQueryRequest.getContext() map so custom plugins can use it -- but i am 100% opposed to having any requesthandlers/components ship with Solr that require it to work -- because those would be completely non-functional for embedded Solr users.

In a lot of cases, i think it probably makes more sense to ask that the client include the information directly as SolrParams -- but that generally assumes that a client that knows about Solr conventions is constructing the request -- which doesn't work as well now that more and more people want to let end user browser/clients talk directly to Solr and use Velocity or custom response writers to format the response.

My preference would be to write components that might care about these sorts of things to utilize regular SolrParams from the SolrQueryRequest, and then add generic logic to the SolrDispatchFilter to map HTTP Headers to SolrParams.  (thus people doing embedded logic can still use the functionality by specifying the appropriate SolrParams)

the key questions with an approach like this would then be fairly simple:
# what type of convention to use for the http header => param naming?
# what should take precedence in the event of name collision: the HTTP Request Query Params, or the HTTP Request Headers?

For people who *really* want direct access to the HttpServletRequest/Response in their custom plugins (like in SOLR-1944), and don't care about about embedded solr users, then we can also include them in the Context (no reason to make a bunch of people re-invent the same DIspatchFilter over and over) but i really feel that nothing that ships with Solr should assume it's there and utilize it directly.



> Expose HttpServletRequest object from SolrQueryRequest object
> -------------------------------------------------------------
>
>                 Key: SOLR-2079
>                 URL: https://issues.apache.org/jira/browse/SOLR-2079
>             Project: Solr
>          Issue Type: Improvement
>          Components: Response Writers, search
>            Reporter: Chris A. Mattmann
>             Fix For: 3.1
>
>         Attachments: SOLR-2079.Quach.Mattmann.082310.patch.txt
>
>
> This patch adds the HttpServletRequest object to the SolrQueryRequest object. The HttpServletRequest object is needed to obtain the client's IP address for geotargetting, and is part of the patches from W. Quach and C. Mattmann.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] Commented: (SOLR-2079) Expose HttpServletRequest object from SolrQueryRequest object

Posted by "Chris A. Mattmann (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SOLR-2079?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12901443#action_12901443 ] 

Chris A. Mattmann commented on SOLR-2079:
-----------------------------------------

bq. The IP may be often that of a load balancer or proxy that sits in front of Solr...

Yep, that's certainly true, but not always the case. Additionally, this kind of sets the stage for more formalized IP detection (or more flexible), but it at least gets us started in that direction. Furthermore, it's likely that a load balancer would be "close" even geographically to the eventual destination server, so geotargetting would still be useful in that sense.

But, I agree this isn't the *only* or *best* solution. I'm just opening the door here to be able to do interesting things...

> Expose HttpServletRequest object from SolrQueryRequest object
> -------------------------------------------------------------
>
>                 Key: SOLR-2079
>                 URL: https://issues.apache.org/jira/browse/SOLR-2079
>             Project: Solr
>          Issue Type: Improvement
>          Components: Response Writers, search
>            Reporter: Chris A. Mattmann
>             Fix For: 3.1
>
>         Attachments: SOLR-2079.Quach.Mattmann.082310.patch.txt
>
>
> This patch adds the HttpServletRequest object to the SolrQueryRequest object. The HttpServletRequest object is needed to obtain the client's IP address for geotargetting, and is part of the patches from W. Quach and C. Mattmann.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] Commented: (SOLR-2079) Expose HttpServletRequest object from SolrQueryRequest object

Posted by "Erik Hatcher (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SOLR-2079?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12901433#action_12901433 ] 

Erik Hatcher commented on SOLR-2079:
------------------------------------

yeah, this has been something I've desired too.  SOLR-1354 is related to this, and I commented there that one way is to do this generically at the dispatch filter level like Ryan has done, taking all HTTP headers and metadata and stuff it into SolrQueryRequest params perhaps prefixed with "_http_" or something like that. 

We need to be sure that we're not tying embedded Solr to container/HTTP classes.

> Expose HttpServletRequest object from SolrQueryRequest object
> -------------------------------------------------------------
>
>                 Key: SOLR-2079
>                 URL: https://issues.apache.org/jira/browse/SOLR-2079
>             Project: Solr
>          Issue Type: Improvement
>          Components: Response Writers, search
>            Reporter: Chris A. Mattmann
>             Fix For: 3.1
>
>         Attachments: SOLR-2079.Quach.Mattmann.082310.patch.txt
>
>
> This patch adds the HttpServletRequest object to the SolrQueryRequest object. The HttpServletRequest object is needed to obtain the client's IP address for geotargetting, and is part of the patches from W. Quach and C. Mattmann.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] Commented: (SOLR-2079) Expose HttpServletRequest object from SolrQueryRequest object

Posted by "Jan Høydahl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SOLR-2079?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12902359#action_12902359 ] 

Jan Høydahl commented on SOLR-2079:
-----------------------------------

I have been using SolrParams to convey metadata from frontends to middleware layer, and I think it has worked really well. In addition, you get it included in the query logs!
As for load balancers, most have an option to convey the client's IP in the "X-Forwarded-For" header.

What if the dispatchFilter adds all HTTP headers to the SolrQueryRequest context. Then we could map explicitly in requestHandler config how to use them:

{code:xml}
<lst name="invariants">
    <str name="_http_remote-ip">$HTTP_HEADERS(X-Forwarded-For, Remote-Address)</str>
</lst>
{code}

This would mean that if HTTP header X-Forwarded-For exists in the context, it will be mapped to param _http_remote-ip, if not, it will use Remote-Address. In this way each application can choose whether to "pollute" the SolrParams with headers or not, choose naming as well as whether it should be invariant or default.

> Expose HttpServletRequest object from SolrQueryRequest object
> -------------------------------------------------------------
>
>                 Key: SOLR-2079
>                 URL: https://issues.apache.org/jira/browse/SOLR-2079
>             Project: Solr
>          Issue Type: Improvement
>          Components: Response Writers, search
>            Reporter: Chris A. Mattmann
>             Fix For: 3.1
>
>         Attachments: SOLR-2079.Quach.Mattmann.082310.patch.txt
>
>
> This patch adds the HttpServletRequest object to the SolrQueryRequest object. The HttpServletRequest object is needed to obtain the client's IP address for geotargetting, and is part of the patches from W. Quach and C. Mattmann.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org