Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9294581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:24:23+00:00 2026-06-18T21:24:23+00:00

I have the following Map / Transform public class PositionSearch : AbstractIndexCreationTask<Employer> { public

  • 0

I have the following Map / Transform

public class PositionSearch : AbstractIndexCreationTask<Employer>
{
    public PositionSearch()
    {
        Map = employers => 
            from employer in employers
            from position in employer.Positions
            select new
            {
               EmployerName = employer.Name,
               SearchSkills = position.RequiredSkills
                                      .Select(x => x.Skill)
            };

        TransformResults = (database, results) => 
            from result in results
            from position in result.Positions
            select new
            {
                EmployerId = result.Id,
                EmployerName = result.Name,
                PositionId = position.Id,
                PositionTitle = position.Title,
                RequiredSkills = position.RequiredSkills
                                    .Select(x => new { x.Skill, x.Proficiency })
            };

        // Any field you are going to use .Search() on should be analyzed.
        Index("SearchSkills", FieldIndexing.Analyzed);
    }
}

I have an employer object with two positions, each with a single skill, “NH” and “MVC”

When I execute the following query I’m getting two position results returned, when I expected one.
Can anyone tell me why this is behaving this way? I’ve got a feeling it’s something to do with a join i’m performing, but I’m not sure.

using (var session = DocumentStore.OpenSession())
{
     var results = session.Query<PositionSearchResultModel, PositionSearch>()
                    .Customize(x => x.WaitForNonStaleResults())
                        .Search(x => x.SearchSkills, "NH")
                    .OfType<PositionSearchResultModel>().ToList();

      Assert.AreEqual(1, results.Count());
}

I’m wanting to use transform so that I can access the Temp-Index-Score meta data for ordering, I’ve been unable to access the meta data without a transform so far.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T21:24:25+00:00Added an answer on June 18, 2026 at 9:24 pm

    You are indexing the Employer document. The search found a document that contained the skill in question, and then you asked to transform the document.

    The way you had it before is projecting from the index, which is the only way you are going to get the specific position found as part of your results.

    I really think you would be happier with Position as it’s own document…

    public class Employer
    {
        public string Id { get; set; }
        public string Name { get; set; }
    }
    
    public class Position
    {
        public string Id { get; set; }
        public string EmployerId { get; set; }
        public string Title { get; set; }
        public string Location { get; set; }
        public ICollection<SkillProficiency> RequiredSkills { get; set; }
    }
    

    This may seem more relational in thinking, but it works just fine in RavenDB, and it will be much easier to query than what you are doing now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code private Map<KEY, Object> values = new HashMap<KEY, Object>(); public
I have the following mapping: public class LogEntryMap { public LogEntryMap() { Map.Id(x =>
I have the following map: std::map<u_long, std::vector<CChatContainer*> >m_Container; class CChatContainer { public: CChatContainer() {
I have the following code: Map<String, ObjectType> objectMap = new HashMap<String, ObjectType>(); for (ObjectType
If I have following map: NavigableMap<Integer,String> nmap = new TreeMap<Integer,String>(); nmap.put(3, Three); nmap.put(1, One);
I have the following map. I wish to map BasketItem to the class Product.
I have the following Map: Map<String, List<String>> map = new HashMap<String, List<String>>(); which is
suppose i have the following: boost::unordered_map< string , someValueType > map; someValueType& value =
I have the following function: func addCatsToMap(m map[string][]CatHouse, meowId int, treats Set, dog *Dog)
I have the following enum how do i map in jna ?? This enum

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.