эластичный поиск подходит для этой ситуации или другой технологии? - PullRequest
0 голосов
/ 06 сентября 2018

Я хочу использоватьasticsearch вместо сервера sql, но мой sql очень сложный, я не знаю es или какая база данных или nosql могут соответствовать этой ситуации. мой sql такой, возможно ли использовать эластичный поиск для этого? спасибо всем вашим предложением. sql создает две временные таблицы, но соединение выполняется слишком медленно и слишком много или объединяет все.

DECLARE @c1 TABLE(
    communityID INT PRIMARY KEY(communityID)
) INSERT INTO @c1 SELECT
    communityID
FROM
    d_community_allocation WITH(nolock)
WHERE
    flag = 1
AND departmentID = 735
ORDER BY
    communityID
DECLARE @c0 TABLE(
    communityID INT PRIMARY KEY(communityID)
) INSERT INTO @c0 SELECT
    communityID
FROM
    d_community_allocation WITH(nolock)
WHERE
    flag = 0
AND departmentID = 735
ORDER BY
    communityID SELECT
        rc AS TotalItems,
        a.realtyID AS RealtyID,
        a.districtID AS DistrictID,
        a.district_name AS DistrictName,
        a.community_indexID AS AreaID,
        a.community_index_name AS AreaName,
        a.communityID AS CommunityID,
        a.community_name AS CommunityName,
        a.community_alias AS CommunityAliasName,
        a.buildingID AS BuildingID,
        a.building_name AS BuildingName,
        a.roomID AS RoomID,
        a.room_name AS RoomName,
        a.floor_num AS FloorNum,
        a.floor_name AS FloorName,
        a.source_type AS SourceType,
        a.trade_status AS TradeStatus,
        a.property_type AS PropertyType,
        a.property_start_date AS PropertyStartDate,
        a.property_end_date AS PropertyEndDate,
        a.[address] AS Address,
        a.special_flag AS IsSpecial,
        a.lock_flag AS IsLock,
        a.trade_type AS TradeType,
        a.realty_status AS RealtyStatus,
        a.delivery_date AS DeliveryDate,
        a.rent_end_date AS RentEndDate,
        a.original_register_date AS OriginalRegisterDate,
        a.rent_commission_date AS RentCommissionDate,
        a.sale_commission_date AS SaleCommissionDate,
        a.filing_start_date AS FilingStartDate,
        a.filing_end_date AS FilingEndDate,
        a.sale_price AS SalePrice,
        a.rent_price AS RentPrice,
        a.base_price AS BasePrice,
        a.sale_unit_price AS SaleUnitPrice,
        a.rent_unit_price AS RentUnitPrice,
        a.transfer_fee AS TransferFee,
        a.management_fee AS ManagerialFee,
        a.management_fee_unit AS ManagementFeeUnit,
        a.air_conditioning_fee AS AirConditioningFee,
        a.construction_area AS ConstructionArea,
        a.usage_area AS UsageArea,
        a.transmission_area AS TransmissionArea,
        a.pay_type AS PayType,
        a.construction_type AS ConstructionType,
        a.shop_type AS ShopType,
        a.office_type AS OfficeType,
        a.commission_type AS CommissionType,
        a.commission_num AS CommissionNum,
        a.property_num AS PropertyNum,
        a.view_type AS ViewType,
        a.key_num AS KeyNum,
        a.filing_num AS FilingNum,
        a.rent_employeeID AS RentEmployeeID,
        a.sale_employeeID AS SaleEmployeeID,
        a.key_employeeID AS KeyEmployeeID,
        a.sole_agent_employeeID AS SoleAgentEmployeeID,
        a.filing_employeeID AS FilingEmployeeID,
        a.owner_employeeID AS OwnershipEmployeeID,
        a.decoration_level AS DecorationLevel,
        a.room_num AS RoomNums,
        a.living_room_num AS LivingRoomNums,
        a.toilet_num AS ToiletNums,
        a.balcony_num AS BalconyNums,
        a.face_orientation AS FaceOrientation,
        a.shop_location AS ShopLocation,
        a.shop_trade_type AS ShopTradeType,
        a.room_depth AS RoomDepth,
        a.room_width AS RoomWidth,
        a.room_height AS RoomHeight,
        a.air_conditioner_type AS AirConditionerType,
        a.[returns] AS Returns,
        a.toilet AS ToiletType,
        a.office_class AS OfficeClass,
        a.overtime_air_conditioning_fee AS OvertimeAirConditioningFee,
        a.realty_type AS RealtyType,
        a.separated_num AS SeparatedNum,
        a.memo AS Memo,
        a.use_type AS UseType,
        a.image_flag AS IsHavingImage,
        a.unit_4rent_price AS UnitofRentPrice,
        a.unit_4rentunit_price AS UnitofRentUnitPrice,
        a.floors_total AS FloorsTotal,
        a.last_followup_date AS LastFollowupDate,
        a.last_update_date AS LastUpdateDate,
        a.last_realty_status_date AS LastRealtyStatusDate,
        a.last_price_date AS LastPriceDate,
        a.filing_department_name AS FilingDepartmentName,
        a.filing_employee_name AS FilingEmployeeName,
        a.sole_agent_department_name AS SoleAgentDepartmentName,
        a.sole_agent_employee_name AS SoleAgentEmployeeName,
        a.key_department_name AS KeyDepartmentName,
        a.key_employee_name AS KeyEmployeeName,
        a.realty_num AS RealtyNum,
        a.sale_department_name AS SaleDepartmentName,
        a.sale_employee_name AS SaleEmployeeName,
        a.rent_department_name AS RentDepartmentName,
        a.rent_employee_name AS RentEmployeeName,
        a.register_employeeID AS RegisterEmployeeID,
        a.register_employee_name AS RegisterEmployeeName,
        a.register_departmentID AS RegisterDepartmentID,
        a.register_department_name AS RegisterDepartmentName,
        a.sale_departmentID AS SaleDepartmentID,
        a.rent_departmentID AS RentDepartmentID,
        a.key_departmentID AS KeyDepartmentID,
        a.sole_agent_departmentID AS SoleAgentDepartmentID,
        a.filing_departmentID AS FilingDepartmentID,
        a.sole_agent_employeeID AS SoleAgentEmployeeID,
        a.stations AS Stations,
        a.delete_flag AS DeleteFlag,
        a.base_unit_price AS BaseUnitPrice,
        a.transmission_area_chi AS ConstructionAreaChi,
        a.shop_trade_name AS ShopTradeName,
        a.realty_floors AS RealtyFloors,
        a.air_conditioning_fee_unit AS AirConditioningFeeUnit,
        a.overtime_air_conditioning_fee_unit AS OvertimeAirConditioningFeeUnit,
        a.usage_ratio AS UsageRatio,
        a.dictionary_flag AS DictionaryFlag,
        a.bamboo_flag AS BambooFlag,
        a.opening_datetime AS OpeningDateTime,
        getdate() AS CurrentServiceDate,
        a.certification_years AS CertificationYears,
        a.certification_date AS CertificationDate,
        a.original_price AS OriginalPrice,
        a.family_unique AS FamilyUnique,
        a.rent_agency_flag AS RentAgencyFlag,
        a.facilities AS Facilities,
        a.commission_date AS CommissionDate,
        a.ex_rent_employeeID AS ExRentEmployeeID,
        a.ex_rent_employee_name AS ExRentEmployeeName,
        a.ex_rent_departmentID AS ExRentDepartmentID,
        a.ex_rent_department_name AS ExRentDepartmentName,
        a.ex_sale_employeeID AS ExSaleEmployeeID,
        a.ex_sale_employee_name AS ExSaleEmployeeName,
        a.ex_sale_departmentID AS ExSaleDepartmentID,
        a.ex_sale_department_name AS ExSaleDepartmentName,
        a.commitment_flag AS IsHavingCommitment,
        a.last_encounter_date AS LastEncounterDateTime,
        a.inspect_status AS InspectStatus,
        a.last_inspect_time AS LastInspectTime,
        a.LimitCommissionDate AS RealtyLimitCommission,
        a.rent_price_up_or_down AS RentPriceUpOrDown,
        a.sale_price_up_or_down AS SalePriceUpOrDown,
        a.HouseCheck_flag AS HouseCheckflag,
        a.Certificate_flag AS Certificateflag,
        a.last_salesman_followup_date AS LastSalesmanFollowupDate,
        a.phone_input_employeeId AS PhoneInputEmployeeId,
        a.phone_input_employee_name AS PhoneInputEmployeeName,
        a.phone_input_departmentId AS PhoneInputDeptId,
        a.phone_input_department_name AS PhoneInputDeptName,
        a.survey_employeeId AS SurveyEmployeeId,
        a.survey_employee_name AS SurveyEmployeeName,
        a.survey_departmentId AS SurveyDeptId,
        a.survey_department_name AS SurveyDeptName,
        a.rent_delegation_employeeId AS RentDelegationEmployeeId,
        a.rent_delegation_employee_name AS RentDelegationEmployeeName,
        a.rent_delegation_departmentId AS RentDelegationDeptId,
        a.rent_delegation_department_name AS RentDelegationDeptName,
        a.sale_delegation_employeeId AS SaleDelegationEmployeeId,
        a.sale_delegation_employee_name AS SaleDelegationEmployeeName,
        a.sale_delegation_departmentId AS SaleDelegationDeptId,
        a.sale_delegation_department_name AS SaleDelegationDeptName,
        a.area_created AS AreaCreated
    FROM
        realty a
    INNER JOIN(
        SELECT
            TOP 500 MAX(rn) OVER(partition BY 1) AS rc ,*
        FROM
            (
                SELECT
                    row_number() OVER(

                        ORDER BY
                            bamboo_flag DESC,
                            rent_agency_flag DESC,
                            commission_date DESC,
                            realtyID DESC
                    ) AS rn,
                    a.realtyID
                FROM
                    (
                        SELECT
                            b.realtyID,
                            b.bamboo_flag,
                            b.rent_agency_flag,
                            commission_date
                        FROM
                            realty b WITH(nolock)
                        INNER JOIN @c1 a ON a.communityID = b.communityID
                        WHERE
                            realty_type = @param0
                        AND delete_flag = 0
                        AND(b.realty_status = @param1)
                        AND(
                            (
                                b.lock_flag = 0
                                AND(
                                    (((b.trade_type = 0) AND 1 = 1))
                                    OR(
                                        (
                                            (b.trade_type = 1)
                                            OR(b.trade_type = 2)
                                        )
                                        AND 1 = 1
                                    )
                                )
                            )
                            OR(
                                b.lock_flag = 1
                                AND(
                                    (
                                        (b.trade_type = 1 OR b.trade_type = 2)
                                        AND 1 = 1
                                    )
                                    OR(b.trade_type = 0 AND 1 = 1)
                                )
                            )
                        )
                        UNION ALL
                            SELECT
                                b.realtyID,
                                b.bamboo_flag,
                                b.rent_agency_flag,
                                commission_date
                            FROM
                                realty b WITH(nolock)
                            INNER JOIN @c0 a ON a.communityID = b.communityID
                            WHERE
                                realty_type = @param0
                            AND delete_flag = 0
                            AND(b.realty_status = @param1)
                            AND(
                                (
                                    b.lock_flag = 0
                                    AND(
                                        (((b.trade_type = 0) AND 1 = 1))
                                        OR(
                                            (
                                                (b.trade_type = 1)
                                                OR(b.trade_type = 2)
                                            )
                                            AND 1 = 1
                                        )
                                    )
                                )
                                OR(
                                    b.lock_flag = 1
                                    AND(
                                        (
                                            (b.trade_type = 1 OR b.trade_type = 2)
                                            AND 1 = 1
                                        )
                                        OR(b.trade_type = 0 AND 1 = 1)
                                    )
                                )
                            )
                    ) a
            ) c
        WHERE
            rn > 0
    ) b ON a.realtyID = b.realtyID
    ORDER BY
        bamboo_flag DESC,
        rent_agency_flag DESC,
        commission_date DESC,
        b.realtyID DESC ',N'@param0 INT ,@param1 INT ',@param0=1201,@param1=0
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...