locked
advanced query problem RRS feed

  • Question

  • I am trying to build a query that will search for all desktop sized images using a textbox in vb.net 2.0, here is my code.

    Code Snippet

    advquery = txtQuery.Text + " filterui:imagesize-desktop_w_" + Screen.PrimaryScreen.Bounds.Width.ToString + "+filterui:imagesize-desktop_h_" + Screen.PrimaryScreen.Bounds.Height.ToString


    this will not work as I get a null reference error

    This will work

    Code Snippet

    advquery = txtQuery.Text + " filterui:imagesize-large"


    What am I doing wrong?

    Please advise.

    Thank you

    JW
    Friday, January 2, 2009 12:57 AM

Answers

  • If you are using SOAP, your query needs to be "dog filterui:imagesize-desktop_w_1152 filterui:imagesize-desktop_h_864" without any '+' characters in between the refinements and the actual query string. SOAP has its own encoding and "+" is different from space in SOAP encoding.

    Thanks

     

    Friday, January 2, 2009 8:16 PM

All replies

  • Hi,

    Your query looks fine to me. Where in your code are you hitting a null reference exception? If its while processing the results, then can you please run the same query on http://www.live.com/?scope=images and check if you are getting any results?If  yes, please provide the exact query so that we can investigate the issue with the image API.

    Thanks

     

     

    Friday, January 2, 2009 1:53 AM
  • I am getting the null reference in my for/next loop at next.

    Code Snippet

    Public Sub printPic(ByVal response As SearchResponse)

    ' Create a new StringBuilder to accumulate the text to be displayed in the WebBrowser

    ' control when the search is complete and all results are returned.

    Dim sb As New StringBuilder()

    sb.EnsureCapacity(8000)

    Dim result As ImageResult

    ' Set up the HTML tags for the output returned from the search.

    sb.Append("<HTML><BODY>")

    sb.Append("<style>body {margin: 0px; padding: 0px; left: 0px; top: 0px; font-size:13px; font-family: Verdana, Arial, Helvetica, sans-serif;}")

    sb.Append("a {font-family: Verdana; color: #006699; text-decoration: none; }")

    sb.Append("a:hover {text-decoration: underline;}")

    sb.Append("IMG {border:0px;}")

    sb.Append("</style>")

    With response

    ' Using foreach, loop through all the SourceResponses in the SearchResponse.

    For Each result In response.Image.Results

    With result

    sb.Append("<CENTER>" + .MediaUrl + "</CENTER><br>")

    sb.Append("<CENTER><IMG SRC=""" + .MediaUrl + """/></CENTER>")

    imgurl = .MediaUrl

    myImage = LoadImageFromUrl(imgurl)

    End With

    Next

    End With

    ' Close the BODY and HTML tags.

    sb.Append("</BODY></HTML>")

    ' Set the text of the WebBrowser control to the HTML contained in the StringBuilder.

    WebBrowser1.DocumentText = sb.ToString

    End Sub

     

     

    Here is the query for "dog" from http://www.live.com/?scope=images

    It does work fine

    http://search.live.com/images/results.aspx?q=dog+filterui:imagesize-desktop_w_1152+filterui:imagesize-desktop_h_864&scope=images&qs=n&FORM=I6IR

    Friday, January 2, 2009 3:28 AM
  • If you are using SOAP, your query needs to be "dog filterui:imagesize-desktop_w_1152 filterui:imagesize-desktop_h_864" without any '+' characters in between the refinements and the actual query string. SOAP has its own encoding and "+" is different from space in SOAP encoding.

    Thanks

     

    Friday, January 2, 2009 8:16 PM
  • Thank you. It works fine now.

    Also, does anyone know where I can find more information about queries besides trial and error playing with live.com? I have had no luck finding any documentation. Thanks.

    Saturday, January 3, 2009 3:08 AM
  • You can refer to the link below that explains how to construct advanced queries on live.com. It also links to other topics such as advance search keywords.

    http://help.live.com/Help.aspx?market=en-US&project=WL_Searchv1&querytype=topic&query=WL_SEARCH_REF_AdvancedSearch.htm

    Unfortunetely as far as documentation on how to use refinements like filter: with query strings on the image vertical is concerned, we don't have a public facing document as of now. Thank you for bringing it to our attention though. I have brought it to the notice of the team and we will add it shortly.

    Thanks!

     

    Monday, January 5, 2009 11:47 PM