Stock indexes finished with tiny gains Wednesday as retailers jumped after a strong hiring forecast from Target and energy companies rose along with oil prices.

Companies that sell everything from clothing to electronics rose after Target said it will hire 100,000 workers for the holiday season, about 30,000 more than it did a year ago. Energy companies rose after the U.S. government said oil and gasoline stockpiles shrank last week.

advertisement | advertise on newsday

Those gains were almost canceled out as technology and health care companies, which have led the market higher this year, slipped.

With stocks at record highs, investors hunted for bargains. Retailers and energy and telecommunications companies have all struggled this year and finished higher Wednesday.

The Standard & Poor’s 500 index added 1.89 points, or 0.1 percent, to 2,498.37. The Dow Jones industrial average picked up 39.32 points, or 0.2 percent, to 22,158.18. The Nasdaq composite rose 5.91 points, or 0.1 percent, to 6,460.19.

Apple slipped again. Investors appeared worried about the $999 price tag of the tenth-anniversary iPhone X as well as its later launch date in early November. That could affect Apple’s revenue in the next few quarters. Investors seemed to like some of Apple’s plans Tuesday, including new features that are being added to the Apple Watch. The stock lost $1.21 to $159.65.