Hello-

I'm working on a SearchComponent that should limit results to entries within a geographic range. I would love some feedback to make sure I'm not building silly queries and/or can change them to be better. I have four fields:

  <field name="north" type="sfloat" ... />
  <field name="south" type="sfloat" ... />
  <field name="east"  type="sfloat" ... />
  <field name="west"  type="sfloat" ... />

The component looks for a "bounds" argument and parses out the NSEW corners. Currently, I'm building a boolean query and adding that to the filter list:

      FieldType ft = req.getSchema().getFieldTypes().get( "sfloat" );

      BooleanQuery range = new BooleanQuery( true );
range.add( new ConstantScoreRangeQuery( "north", null, ft.toInternal(n), true, true ), BooleanClause.Occur.MUST ); range.add( new ConstantScoreRangeQuery( "south", ft.toInternal(s), null, true, true ), BooleanClause.Occur.MUST ); range.add( new ConstantScoreRangeQuery( "east", null, ft.toInternal(e), true, true ), BooleanClause.Occur.MUST ); range.add( new ConstantScoreRangeQuery( "west", ft.toInternal(w), null, true, true ), BooleanClause.Occur.MUST );

essentially, this is:
 +north:[* TO nnn] +south:[sss TO *] +east:[* TO eee] +west:[www TO *]


Would this be better as four individual filters?

Additionally, I could chunk the world into a grid and see index if a point exists within a square. This could potentially cut out many results with a simple term query, but I don't know if it is worthwhile since I will need to run the points through a range query at the end anyway.

Any thoughts of feedback would be great.

thanks
ryan



Reply via email to