You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SearchAround操作后聚合ObjectSet遭遇数据量超限错误的解决方案咨询

Fixing "ObjectSetTooLargeForSearchAround" Error in Phonograph

Got it, let's break down how to fix this issue with your Phonograph query. The error makes it clear: the passenger object set generated by your searchAroundPassengers() call is way over the 100k limit, so operations like take() or aggregations can't run on it directly. Here are practical, actionable solutions tailored to your use case:

1. Shrink the source flight set before running Search Around

The root problem is that your initial flight filter only uses departureAirportCode, which leaves you with a huge set of flights. Adding more restrictive filters here will drastically reduce the number of passengers pulled in the subsequent searchAround step.

For example, you could add a date range, flight status, or route filter:

const filteredFlights = Objects.search()
  .flights()
  .filter(flight => flight.departureAirportCode.exactMatch(airportCode))
  .filter(flight => flight.departureDate.between('2022-01-01', '2022-01-31')) // Narrow to a specific month
  .filter(flight => flight.status.exactMatch('ACTIVE')); // Only include active flights

const passengers = filteredFlights
  .searchAroundPassengers()
  .filter(passenger => passenger.passengerAttribute.exactMatch(value))
  .groupBy(passenger => passenger.countryOfOrigin)
  .count();

If you can't narrow down flights further with filters, use batching to process flights in chunks. This ensures each batch's associated passengers stay under the 100k limit:

let aggregatedResults = {};
let offset = 0;
const batchSize = 5000; // Adjust based on average passengers per flight

while (true) {
  // Grab a batch of flights
  const flightBatch = Objects.search()
    .flights()
    .filter(flight => flight.departureAirportCode.exactMatch(airportCode))
    .skip(offset)
    .take(batchSize);

  // Process the batch's passengers
  const batchPassengers = flightBatch
    .searchAroundPassengers()
    .filter(passenger => passenger.passengerAttribute.exactMatch(value))
    .groupBy(p => p.bookingClass)
    .count();

  // Exit loop if no more results
  if (Object.keys(batchPassengers).length === 0) break;

  // Merge batch results into the final set
  for (const [classType, count] of Object.entries(batchPassengers)) {
    aggregatedResults[classType] = (aggregatedResults[classType] || 0) + count;
  }

  offset += batchSize;
}

2. Reverse the query direction

Instead of starting with flights and pulling passengers, start with passengers that match your attribute filter, then pull their associated flights and filter by departure airport. This way you shrink the passenger set first, before linking to flights:

const passengersDepartingFromAirport = Objects.search()
  .passengers()
  .filter(passenger => passenger.passengerAttribute.exactMatch(value))
  .searchAroundFlights()
  .filter(flight => flight.departureAirportCode.exactMatch(airportCode))
  .searchAroundPassengers(); // Optional: return to passenger object set for further operations

// Now you can safely run aggregations or take()
const passengerCount = passengersDepartingFromAirport.groupBy(p => p.id).count();

This works best if your passenger attribute filter eliminates a large portion of the total passenger pool upfront.

3. Use pre-aggregated views or server-side analytics

If your Phonograph setup supports it, create a pre-aggregated object view that combines flight and passenger data filtered by common criteria (like departure airport and passenger attributes). This lets you query the pre-computed view instead of running real-time cross-object searches, which avoids the size limit entirely.

Alternatively, check if Phonograph supports server-side aggregation on the initial flight set before linking to passengers. For example, aggregate flights by departure airport first, then pull aggregated passenger metrics per flight group.


内容的提问来源于stack exchange,提问作者Charitini Skaltsari

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 18:39:08