HashtagSell / posting-api

API for storage and retrieval of posting details for Hashtagsell
0 stars 0 forks source link

Elasticsearch distance sorting #35

Closed that1guy closed 9 years ago

that1guy commented 9 years ago

Returned items are not sorted by distance.

brozeph commented 9 years ago

[verified]

that1guy commented 9 years ago

Items in page three are closer to the user user than items on page two.

Page two query
http://localhost:4043/v1/postings/?start=35&count=35&filters[mandatory][contains][heading]=macbook%20air&filters[optional][exact][categoryCode]=VAUT,RHFR,SELE,VPAR,SAPP,SAPL,VMOT&geo[coords]=-122.399,37.799&geo[min]=0&geo[max]=8046720
Page two response... The LAST result is 67706 meters distance from geo.coords
{
.
.
.
    {
      "username": "jmsgp-4947222740@sale.craigslist.org",
      "heading": "Air Jordan 2.5 Team Mens size 9.5",
      "body": "\n Used. 100% authentic. No original box. Mens shoes size 9.5. Serious buyers only. No trades, cash only. Asking price $35 obo.\n ",
      "expiresAt": "2015-05-10T22:40:08.000Z",
      "categoryCode": "SAPP",
      "annotations": {
        "html_data_size": "14838",
        "source_subloc": "sby",
        "source_subcat": "cla|clo",
        "source_loc": "sfbay",
        "original_posting_date": "1427223880",
        "gzip_data_size": "4396",
        "source_account": "jmsgp-4947222740@sale.craigslist.org",
        "source_state": "California",
        "proxy_ip": "104.131.82.175:22225",
        "source_neighborhood": "san jose south",
        "source_cat": "sss",
        "source_heading": "Air Jordan 2.5 Team Mens size 9.5",
        "source_continent": "USA"
      },
      "postingId": "0ce7d993fa18434bab580d483adcebe6",
      "language": "EN",
      "images": [
        {
          "full": "http://images.craigslist.org/00r0r_gPlSFmW7d4u_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/01414_7Oy07PrRGhR_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/01515_iu30Sk1MFY2_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00k0k_9v8BQnPz9ig_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00N0N_dPDXpGtVcKK_600x450.jpg"
        }
      ],
      "geo": {
        "status": 5,
        "accuracy": 7,
        "coordinates": [
          -121.89496,
          37.33939
        ],
        "distance": 67706.68901721957
      },
      "createdAt": "2015-03-26T22:40:08.000Z",
      "askingPrice": {
        "value": "35",
        "currency": "USD"
      },
      "external": {
        "threeTaps": {
          "timestamp": 1427409608,
          "status": "for_sale",
          "location": {
            "state": "USA-CA",
            "region": "USA-SFO-SOU",
            "metro": "USA-SFO",
            "locality": "USA-SFO-DOJ",
            "formatted": "San Jose, CA, USA",
            "county": "USA-CA-STL",
            "country": "USA",
            "city": "USA-SFO-SJO"
          },
          "categoryGroup": "SSSS",
          "category": "SAPP",
          "id": 1965031496
        },
        "source": {
          "url": "http://sfbay.craigslist.org/sby/clo/4947222740.html",
          "id": "4947222740",
          "code": "CRAIG"
        }
      }
    }
  ],
  "total": 801
}
Page three query
http://localhost:4043/v1/postings/?start=70&count=35&filters[mandatory][contains][heading]=macbook%20air&filters[optional][exact][categoryCode]=VAUT,RHFR,SELE,VPAR,SAPP,SAPL,VMOT&geo[coords]=-122.399,37.799&geo[min]=0&geo[max]=8046720
Page three response.. The first item in page three is not a greater distance the last item on page two.
{
  "options": {
    "count": "35",
    "filters": {
      "mandatory": {
        "contains": {
          "heading": "macbook air"
        }
      },
      "optional": {
        "exact": {
          "categoryCode": [
            "VAUT",
            "RHFR",
            "SELE",
            "VPAR",
            "SAPP",
            "SAPL",
            "VMOT"
          ]
        }
      }
    },
    "geo": {
      "coords": [
        -122.399,
        37.799
      ],
      "min": 0,
      "max": 8046720
    },
    "sort": {},
    "start": "70"
  },
  "results": [
    {
      "username": "f6ckj-4974203854@sale.craigslist.org",
      "heading": "Macbook Air 11 i7 2Ghz 8GB RAM 256GB Drive  Bundle Or Best Offer",
      "body": "\n *If the ad is up then the Macbook Air is still available**\n**Open to cash offers, dont be shy. The worse I could say is no.**\n***check your spam box because Craigslist will occasionally direct inquiries and replies into your spam folder***\nPlease read this ad in full\nMy boss is a bit of an eccentric but a really cool guy. He was going to throw it away because the keyboard stopped working which frustrated the hell out of him. I do not know what happend.\nTaking into consideration that the POWER button is connected to the keyboard, I felt it would be unwise to turn off the Macbook Air. IE: If the keyboard doesn`t work then the power button most likely will not function. Its just a theory. The trackpad IS FUNCTIONAL. It`s only the keyboard that does not work.\nI picked up a genuine Apple Bluetooth keyboard and magic mouse. Paired it up and voila! A perfectly fine Macbook Air that I`ve been using for over a year. It has never been turned off since the day I got it. Only 128 charge cycles!\nMy boss gave me a new PC laptop because he got sick and tired of looking at his old Macbook Air and request that I never bring it into the office so I no longer have a need for this Macbook Air.\nBreakdown of cost.\n**The Macbook Air is a BTO (Built To Order) adding $550 worth of options from base.\nOPTIONS: 2.00 GHz Core i7 $150, 8GB of 1600Mhz DDR3 RAM $100, 256GB of flash storage $300 **\n1. Apple Macbook Air 11\" (11.6\") Mid-2012 $1099 (base) +$550 (options) = $1649\n2. Genuine Apple Wireless Bluetooth Keyboard = $69 (batteries included)\n3. Genuine Apple Wireless Bluetooth Magic Mouse = $69 (batteries included)\n4. Bose Companion 2 Series 2 (II) Multimedia Speakers = $99\n5. Genuine Apple Display port to DVI adapter $29 (if you want to use an external monitor with DVI port)\n6. DVI Cable $7 (will allow you to connect the air to external monitor using the included Apple DVI adapter)\n7. Genuine Apple Magsafe 45w charger\nTotal is $1922 and after tax its almost $2100!!\nGranted I`m not asking for that figure since I did get it for free. My only cost was the keyboard, mouse, and Bose speakers. With all that being said I AM OPEN TO CASH OFFERS =) Don`t be shy, the worse I could say is no.\nFresh install of Mavericks 10.9.5 to factory settings. I will leave it up to you if you want to upgrade to Yosemite. No additional software. The Macbook Air is capable of lasting a while but I always bring a charger with me just in case. Again, I`ve never turned it off but then again turning off a laptop is unnecessary and simply closing the lid and putting it into hibernation is fine.\nAgain, I`m open to offers. I respond to all inquires. Cash only. You are more than welcome to test it. If the ad is up then you can assume its still available. Located in San Francisco.\nYosemite, X, Macbook Pro, Mac, 13\", Leopard, Mini, desktop, iMac, PC, portable, dell, Samsung, gateway, AMD, sold as is , alienware, custom, Thinkpad, Toshiba, Lenovo, HP, Pavilion, 15\", ssd, 2.0, 256 , gig , gb , 11 , 13 , 8 gb, SSD\n ",
      "expiresAt": "2015-05-26T18:16:56.000Z",
      "categoryCode": "SELE",
      "annotations": {
        "year": "1922",
        "html_data_size": "24767",
        "source_subloc": "sfc",
        "source_subcat": "sya|sys",
        "source_loc": "sfbay",
        "gzip_data_size": "6219",
        "source_account": "f6ckj-4974203854@sale.craigslist.org",
        "source_state": "California",
        "proxy_ip": "104.236.81.110:22225",
        "source_neighborhood": "ingleside / SFSU / CCSF",
        "source_cat": "sss",
        "source_heading": "Macbook Air 11\" i7 2Ghz 8GB RAM 256GB Drive + Bundle *Or Best Offer*",
        "source_continent": "USA"
      },
      "postingId": "12d26d4866e04f91a218f49b38980984",
      "language": "EN",
      "images": [
        {
          "full": "http://images.craigslist.org/00E0E_ictDYZlxKzc_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00W0W_k4vBvH0FU7K_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00404_a3pwWHVsm0M_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00G0G_1oaJV1wNfoc_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00I0I_8XlAIKfzDYa_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00c0c_jAChJfPFfIn_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00V0V_9YrgkeMsVBX_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00i0i_aJUmBqn5sGD_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00303_h3XoDHxD6F8_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00J0J_2ZKdfLQIyj4_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/01111_gY8aRrjKv7z_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00N0N_3C1P0hAK9zX_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00g0g_3SggzFHTdcr_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/01010_iVTLKHvZqAU_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00505_3AxntMri8GP_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00A0A_44NF27k5qmq_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00t0t_3WafOSEovfF_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00000_iLF5LlRbWEl_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00F0F_aQ5SfeCyUdE_600x450.jpg"
        }
      ],
      "geo": {
        "status": 5,
        "accuracy": 7,
        "coordinates": [
          -122.41942,
          37.77493
        ],
        "distance": 3221.912320852126
      },
      "createdAt": "2015-04-11T18:16:56.000Z",
      "askingPrice": {
        "value": "945",
        "currency": "USD"
      },
      "external": {
        "threeTaps": {
          "timestamp": 1428776216,
          "status": "for_sale",
          "location": {
            "state": "USA-CA",
            "region": "USA-SFO-SAF",
            "metro": "USA-SFO",
            "locality": "USA-SFO-SOO",
            "formatted": "San Francisco, CA, USA",
            "county": "USA-CA-SAF",
            "country": "USA",
            "city": "USA-SFO-SNF"
          },
          "categoryGroup": "SSSS",
          "category": "SELE",
          "id": 2022007454
        },
        "source": {
          "url": "http://sfbay.craigslist.org/sfc/sys/4974203854.html",
          "id": "4974203854",
          "code": "CRAIG"
        }
      }
    },
    {
      "username": "n8pfb-4948072107@sale.craigslist.org",
      "heading": "Like New Macbook Air 13.3",
      "body": "\n Purchased in 2014 and still under apple warranty. No scratches or anything. Barely used like new. Only has 7 battery cycles. Comes with original box, keyboard cover, charger and extension cord. Text me at 415-819-578two if interested. Thanks.\n13.3-inch (diagonal) LED-backlit glossy widescreen display, 1440-by-900 resolution\n4GB memory\n128GB flash storage\n720p FaceTime HD camera\nIntel HD Graphics 5000\nUp to 12 hours battery life\nBacklit keyboard\nFree upgrade to osx yosemite\n ",
      "expiresAt": "2015-05-26T04:46:08.000Z",
      "categoryCode": "SELE",
      "annotations": {
        "year": "2014",
        "html_data_size": "12033",
        "source_subloc": "sfc",
        "source_subcat": "sya|sys",
        "source_loc": "sfbay",
        "original_posting_date": "1427275192",
        "gzip_data_size": "4019",
        "source_account": "n8pfb-4948072107@sale.craigslist.org",
        "source_state": "California",
        "proxy_ip": "104.131.59.173:22225",
        "source_neighborhood": "ingleside / SFSU / CCSF",
        "source_cat": "sss",
        "source_heading": "Like New Macbook Air 13.3\"",
        "source_continent": "USA"
      },
      "postingId": "1a5d1f8da9c04acb9609c3d43f4d1079",
      "language": "EN",
      "images": [],
      "geo": {
        "status": 5,
        "accuracy": 7,
        "coordinates": [
          -122.41942,
          37.77493
        ],
        "distance": 3221.912320852126
      },
      "createdAt": "2015-04-11T04:46:08.000Z",
      "askingPrice": {
        "value": "800",
        "currency": "USD"
      },
      "external": {
        "threeTaps": {
          "timestamp": 1428727568,
          "status": "for_sale",
          "location": {
            "state": "USA-CA",
            "region": "USA-SFO-SAF",
            "metro": "USA-SFO",
            "locality": "USA-SFO-SOO",
            "formatted": "San Francisco, CA, USA",
            "county": "USA-CA-SAF",
            "country": "USA",
            "city": "USA-SFO-SNF"
          },
          "categoryGroup": "SSSS",
          "category": "SELE",
          "id": 2020009086
        },
        "source": {
          "url": "http://sfbay.craigslist.org/sfc/sys/4948072107.html",
          "id": "4948072107",
          "code": "CRAIG"
        }
      }
    },
    {
      "username": "tnrdr-4940968166@sale.craigslist.org",
      "heading": "New 60W 85W MagSafe/ MagSafe2 Power Adapter Supply Charger MacBook",
      "body": "\n We carry low-priced, Brand New Magsafe charger for your Macbook Pro and Macbook Air . We currently have:\nT-tip 85w Magsafe for 15\"-21\" Macbook at $29\nT-tip 60w Magsafe for 13\" Macbook at $25\nL- tip 45w Magsafe charger for 11`` Macbook at $25\nL- tip 60w Magsafe charger for 13`` Macbook at $25\nL-tip 85w Magsafe for 15\"-21\" Macbook at $29\nT-tip 60w Magsafe 2 for 13\" Macbook at $28\nT-tip 85w Magsafe 2 for 15\"-21\" Macbook at $34\nEach charger comes with an extension cord, and a detachable prong. In order to provide excellent buying experience for our buyer, we currently offer three convenient location for pick up within San Francisco/ Bay Area(1. Downtown/ 2.Mission/ 3.North Beach. Should you have any question, feel free to contact me @ Danny\nCondition:New (come with box)\n85W L Tip MagSafe\nCompatible Models: MacBook Pro MagSafe A1172 A1222\nVideo Features Condition: Brand New\nVideo Features Output Amp:4.6A\nVideo Features Output Voltage:18.5V\nVideo Features Output Watt:85W\nVideo Features Package content: AC adapter a complete set ready-to-use\nCondition:New (come with box)\n60W L Tip MagSafe\nCompatible:\nA 1150, A1151, A1172, A1184, A1222, A1286, A1290, A1343,\nMA537LL/A, 661-4269, 661-4485, 661-4259, 661-4339, MA357LL/A, MA938LL/A, 661-3994\nApple MacBook Pro: MA463LL/A, MA464LL/A,\nMA090LL, MA600LL, MA601LL, MA092LL/A, MA609LL, MA610LL,\nMA611LL/A, MA895LL/A, MA896LL/A, MA895LL, MA896LL, MA897LL/A,\nCore Duo 1.67 15-inch, 15.4-inch Glossy, 17-inch, Late 2006, Mid 2007 17-inch Santa Rosa, Late 2007 15.4-inch Santa Rosa\nMost Apple MacBook 13\" Laptops\nMost Apple MagSafe MacBook PRO Laptops\nMost Apple MacBook Pro 13\" Laptops\nMacBook 13\" 1.83/2 GHz Core Duo\nMacBook 13\" 1.83/2.16 GHz Core 2 Duo\nCondition:New (come with box)\n60W T Tip MagSafe\nInput: AC 100-240V, 50-60Hz\nOutput: DC 16.5V 3.65A\nPower: 60W\nConnector: magnetic tip 5 pin (T Tip)\nProduct Compatible;\nApple MAC Macbook pro 13 13.3\nA1181 A1184 A 1185 A1330 A1278 A1334 and so on\nMA254LL/A, MA255LL/A, MA472LL/A, MA699LL/A, MA700LL/A, MA701LL/A, MB061LL/B, MB062LL/B, MB063LL/B,\nMB061LL/A, MB062LL/A, MB063LL/A.\nCondition:New (come with box)\n60W T Tip MagSafe2\nFITS MacBook Pro Retina 13-Inch A1425 MD212LL/A MD212 MD213 Magsafe2\nCondition:New (come with box)\n85W T Tip MagSafe2\n85W MagSafe 2 Power Adapter MD506LL/A Model A1424\n ",
      "expiresAt": "2015-05-18T21:01:31.000Z",
      "categoryCode": "SELE",
      "annotations": {
        "year": "2006",
        "html_data_size": "17403",
        "source_subloc": "sfc",
        "source_subcat": "sya|syd",
        "source_loc": "sfbay",
        "original_posting_date": "1426870693",
        "gzip_data_size": "5356",
        "source_account": "tnrdr-4940968166@sale.craigslist.org",
        "phone": "2696614485",
        "source_state": "California",
        "proxy_ip": "107.170.73.167:22225",
        "source_neighborhood": "mission district",
        "source_cat": "sss",
        "source_heading": "New 60W 85W MagSafe/ MagSafe2 Power Adapter Supply Charger MacBook",
        "source_continent": "USA"
      },
      "postingId": "148683a8e1be487d9041eba1170e1442",
      "ebay": null,
      "language": "EN",
      "images": [
        {
          "full": "http://images.craigslist.org/00101_fa5uVjFXAWK_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00j0j_ejQswtRWg34_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00S0S_eMsaS5TDuWA_600x450.jpg"
        },
        {
          "full": "http://images.craigslist.org/00n0n_hTNIyIB3CTa_600x450.jpg"
        }
      ],
      "geo": {
        "status": 3,
        "accuracy": 8,
        "coordinates": [
          -122.4148,
          37.75986
        ],
        "distance": 4567.716706093142
      },
      "createdAt": "2015-04-03T21:01:31.000Z",
      "askingPrice": {
        "value": "25",
        "currency": "USD"
      },
      "external": {
        "threeTaps": {
          "timestamp": 1428094891,
          "status": "for_sale",
          "location": {
            "state": "USA-CA",
            "region": "USA-SFO-SAF",
            "metro": "USA-SFO",
            "locality": "USA-SFO-MSF",
            "formatted": "Mission District, San Francisco, CA, USA",
            "county": "USA-CA-SAF",
            "country": "USA",
            "city": "USA-SFO-SNF"
          },
          "categoryGroup": "SSSS",
          "category": "SELE",
          "id": 1993676791
        },
        "source": {
          "url": "http://sfbay.craigslist.org/sfc/syd/4940968166.html",
          "id": "4940968166",
          "code": "CRAIG"
        }
      }
    },
that1guy commented 9 years ago

Perhaps I should also increase the geo.min value while ALSO increasing increasing the start value? Wouldn't this skip items in the results?