コード例 #1
0
 public function testFiter()
 {
     $s = new Search('');
     $s->addFilter((new Filter('tags', '=', 'Women'))->addOr('tags', '=', 'dress pants'));
     $r = $this->engine->search($s);
     $this->assertEquals($r->results->hits[0]->id, 'f346904e7dcd43c521bff2e6dcfae21a');
     $this->assertEquals($r->results->hits[1]->id, 'c05ef333b5dbd9f31123a65221762395');
 }
コード例 #2
0
$r = $engine->search((new Search('red dress'))->addField('id')->addField('title'));
printResults($r);
//Get all fields including debug fields
$r = $engine->search((new Search('red dress'))->addField('[debug]'));
printResults($r);
//Filter by price < 100
$r = $engine->search((new Search('red dress'))->addFilter(new Filter('price', '<', 100)));
printResults($r);
//A query where we want red dresses in size '2P' or in size '4R' and
$s = new Search('red dress');
$s->addFilter((new Filter('sizes', '=', '2P', '2p2r'))->addOr('sizes', '=', '4R'));
$r = $engine->search($s);
printResults($r);
//A query where we want red dresses under $100 and the top 5 brands returned as facets
$s = new Search('red dress');
$s->addFilter(new Filter('price', '<', 100));
$s->addFacet(new EnumFacet('brand', 5));
$r = $engine->search($s);
printResults($r);
//A query where we want red dresses and the range of prices returned
$s = new Search('red dress');
$s->addFacet(new RangeFacet('price'));
$r = $engine->search($s);
printResults($r);
//A query where we want red dresses and a histogram of their
$s = new Search('red dress');
$s->addFacet(new HistFacet('price', 0, 500, 100));
$r = $engine->search($s);
printResults($r);
//A search with multiple keyed facets on the 'brand' field
$s = new Search('red dress');
コード例 #3
0
	protected function get_additional_team_bio_page_info( $team )
	{
		/* code to get testimonials ordered by date new to old */
 		loadModel( "/entities/testimonials/EntityTestimonial" );
		//$testimonials = EntityTestimonial::GetEntityTeamTestimonialsWithSubTestimonials( $team  );
		$testimonials = EntityTestimonial::GetEntityTestimonialsOrderByOrder( $team );
		$testimonial_dicts = array();
		foreach( $testimonials as $testimonial ) {
			$testimonial_dicts[] = $testimonial->getAsDictionary();
		}
		
		/* get team listings */
		loadModel( "/search/Search" );
		$properties = array();
		$search = new Search();
		$search->addTerm( 'realtor', $team->rebrand_code );
		$search->addOrderBy( 'list_price', false);
		$props = $search->run( 0, 7 );
		$tmp_properties = Property::GetPropertiesFromIdArray($props, PropertyLoadLevel::IDX_SUMMARY, true);
		foreach( $props as $prop ) {
			try{
				$property = $tmp_properties[$prop];
				// add open house
				// $property->open_house = $property->getAllDates( true );
				$temp_pic = $property->get_first_pic();
				if ( is_object( $temp_pic ) ){
					$property->photo = $temp_pic->getUrl();
				} else {
					$property->photo = false;
				}
				$properties[] = $property;
			}
			catch( Exception $e ) {}
		}
		unset($tmp_properties);
		

		/* get team sold listings */
		$sold_properties = array();
		$sold_search = new Search();
		$sold_search->addTerm( 'buyer_seller', $team->rebrand_code );
		$sold_search->addFilter( SearchFilter::SOLD );
		$sold_search->addOrderBy( 'list_price', false);
		$sold_props = $sold_search->run( 0, 3);
		//set idx view to the sold table to get the sold prop info
		IDX::Set_IDX_View_Name( IDX::SOLD );
		$tmp_properties = Property::GetPropertiesFromIdArray($sold_props, PropertyLoadLevel::IDX_SUMMARY, true);

		foreach( $sold_props as $sold_prop ) {
			try{
				$property = $tmp_properties[$sold_prop];
				$temp_pic = $property->get_first_pic();
				if ( is_object( $temp_pic ) ){
					$property->photo = $temp_pic->getUrl();
				} else {
					$property->photo = false;
				}
				$sold_properties[] = $property;
			}
			catch( Exception $e ) {}
		}
		unset($tmp_properties);

		//reset back to normal idx view
		IDX::Set_IDX_View_Name( IDX::MATERIALIZED );

		$tpl_args = array(
			'testimonials' => $testimonial_dicts,
			'properties' => $properties,
			'sold_properties' => $sold_properties,
		);
		return $tpl_args;
 	}
コード例 #4
0
 public function testFilterEscapeChars()
 {
     $s = new Search('');
     $s->addFilter((new Filter('Color', '=', 'Red!\\,|', null, Filter::TYPE_CNF))->addAnd('Color', '!=', 'Blue'));
     $this->assertEquals('q=&filter=' . urlencode('exp=Color:Red\\!\\\\\\,\\|,Color:!Blue/type=cnf'), $s->getUrlString());
 }