How do I append filters to the q parameter?

8 views
Skip to first unread message

PM

unread,
Nov 25, 2012, 1:10:17 PM11/25/12
to Google-Search-...@googlegroups.com
I have a need to use filters such as inurl: as well as allinurl: . An example of query that needs to performed each time a users specifies a query would be apples OR inurl:apples.

This should also not show in the search box i.e. it should only display apples but the inurl: is appended to the query string. Is there a way to do this?

I attempted to use the as_oq i.e. <input type="hidden" name="as_oq" value="inurl:{PARAM[@name='q']/@original_value}" /> however for some odd reason the value does not appear in the query string.

Dave Watts

unread,
Nov 25, 2012, 2:54:21 PM11/25/12
to Google-Search-...@googlegroups.com
> I have a need to use filters such as inurl: as well as allinurl: . An
> example of query that needs to performed each time a users specifies a query
> would be apples OR inurl:apples.
>
> This should also not show in the search box i.e. it should only display
> apples but the inurl: is appended to the query string. Is there a way to do
> this?

These filters are intended to be provided by the user, and are part of
the q parameter, and will therefore show up wherever you're displaying
the q parameter unless you specifically filter them out. For some
terms, like site, there's a corresponding URL parameter you can use
instead (as_sitesearch in the case of site), but I'm not aware of any
direct equivalent for inurl and allinurl.

If you're building the interface, you could use string functions to
filter out the part of the query you don't want to show in the text
field.

> I attempted to use the as_oq i.e. <input type="hidden" name="as_oq"
> value="inurl:{PARAM[@name='q']/@original_value}" /> however for some odd
> reason the value does not appear in the query string.

I don't think you can inject special operators using as_oq.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.

PM

unread,
Nov 25, 2012, 4:10:22 PM11/25/12
to Google-Search-...@googlegroups.com
Thanks Dave. As I am not building a custom or bespoke interface, I was hoping I could achieve this natively.
Reply all
Reply to author
Forward
0 new messages